Class LocalPlayer

All Implemented Interfaces:
CommandSource, SyncedDataHolder, Attackable, EntityAccess, Nameable, ScoreHolder, IAttachmentHolder, IEntityExtension, ILivingEntityExtension, IPlayerExtension, INBTSerializable<CompoundTag>

public class LocalPlayer extends AbstractClientPlayer
  • Field Details

    • LOGGER

      public static final org.slf4j.Logger LOGGER
    • POSITION_REMINDER_INTERVAL

      private static final int POSITION_REMINDER_INTERVAL
      See Also:
    • WATER_VISION_MAX_TIME

      private static final int WATER_VISION_MAX_TIME
      See Also:
    • WATER_VISION_QUICK_TIME

      private static final int WATER_VISION_QUICK_TIME
      See Also:
    • WATER_VISION_QUICK_PERCENT

      private static final float WATER_VISION_QUICK_PERCENT
      See Also:
    • SUFFOCATING_COLLISION_CHECK_SCALE

      private static final double SUFFOCATING_COLLISION_CHECK_SCALE
      See Also:
    • MINOR_COLLISION_ANGLE_THRESHOLD_RADIAN

      private static final double MINOR_COLLISION_ANGLE_THRESHOLD_RADIAN
      See Also:
    • connection

      public final ClientPacketListener connection
    • stats

      private final StatsCounter stats
    • recipeBook

      private final ClientRecipeBook recipeBook
    • ambientSoundHandlers

      private final List<AmbientSoundHandler> ambientSoundHandlers
    • permissionLevel

      private int permissionLevel
    • xLast

      private double xLast
      The last X position which was transmitted to the server, used to determine when the X position changes and needs to be re-transmitted
    • yLast1

      private double yLast1
      The last Y position which was transmitted to the server, used to determine when the Y position changes and needs to be re-transmitted
    • zLast

      private double zLast
      The last Z position which was transmitted to the server, used to determine when the Z position changes and needs to be re-transmitted
    • yRotLast

      private float yRotLast
      The last yaw value which was transmitted to the server, used to determine when the yaw changes and needs to be re-transmitted
    • xRotLast

      private float xRotLast
      The last pitch value which was transmitted to the server, used to determine when the pitch changes and needs to be re-transmitted
    • lastOnGround

      private boolean lastOnGround
    • crouching

      private boolean crouching
    • wasShiftKeyDown

      private boolean wasShiftKeyDown
    • wasSprinting

      private boolean wasSprinting
      the last sprinting state sent to the server
    • positionReminder

      private int positionReminder
      Reset to 0 every time position is sent to the server, used to send periodic updates every 20 ticks even when the player is not moving.
    • flashOnSetHealth

      private boolean flashOnSetHealth
    • input

      public Input input
    • minecraft

      protected final Minecraft minecraft
    • sprintTriggerTime

      protected int sprintTriggerTime
    • yBob

      public float yBob
    • xBob

      public float xBob
    • yBobO

      public float yBobO
    • xBobO

      public float xBobO
    • jumpRidingTicks

      private int jumpRidingTicks
    • jumpRidingScale

      private float jumpRidingScale
    • spinningEffectIntensity

      public float spinningEffectIntensity
    • oSpinningEffectIntensity

      public float oSpinningEffectIntensity
    • startedUsingItem

      private boolean startedUsingItem
    • usingItemHand

      @Nullable private InteractionHand usingItemHand
    • handsBusy

      private boolean handsBusy
    • autoJumpEnabled

      private boolean autoJumpEnabled
    • autoJumpTime

      private int autoJumpTime
    • wasFallFlying

      private boolean wasFallFlying
    • waterVisionTime

      private int waterVisionTime
    • showDeathScreen

      private boolean showDeathScreen
    • doLimitedCrafting

      private boolean doLimitedCrafting
  • Constructor Details

  • Method Details

    • hurt

      public boolean hurt(DamageSource pSource, float pAmount)
      Called when the entity is attacked.
      Overrides:
      hurt in class Player
    • heal

      public void heal(float pHealAmount)
      Heal living entity (param: amount of half-hearts)
      Overrides:
      heal in class LivingEntity
    • startRiding

      public boolean startRiding(Entity pEntity, boolean pForce)
      Overrides:
      startRiding in class Entity
    • removeVehicle

      public void removeVehicle()
      Overrides:
      removeVehicle in class Player
    • getViewXRot

      public float getViewXRot(float pPartialTick)
      Gets the current pitch of the entity.
      Overrides:
      getViewXRot in class Entity
    • getViewYRot

      public float getViewYRot(float pPartialTick)
      Gets the current yaw of the entity
      Overrides:
      getViewYRot in class LivingEntity
    • tick

      public void tick()
      Overrides:
      tick in class AbstractClientPlayer
    • getCurrentMood

      public float getCurrentMood()
    • sendPosition

      private void sendPosition()
    • sendIsSprintingIfNeeded

      private void sendIsSprintingIfNeeded()
    • drop

      public boolean drop(boolean pFullStack)
    • swing

      public void swing(InteractionHand pHand)
      Overrides:
      swing in class LivingEntity
    • respawn

      public void respawn()
      Overrides:
      respawn in class Player
    • actuallyHurt

      protected void actuallyHurt(DamageSource pDamageSrc, float pDamageAmount)
      Deals damage to the entity. This will take the armor of the entity into consideration before damaging the health bar.
      Overrides:
      actuallyHurt in class Player
    • closeContainer

      public void closeContainer()
      Overrides:
      closeContainer in class Player
    • clientSideCloseContainer

      public void clientSideCloseContainer()
    • hurtTo

      public void hurtTo(float pHealth)
      Updates health locally.
    • onUpdateAbilities

      public void onUpdateAbilities()
      Overrides:
      onUpdateAbilities in class Player
    • isLocalPlayer

      public boolean isLocalPlayer()
      Overrides:
      isLocalPlayer in class Player
    • isSuppressingSlidingDownLadder

      public boolean isSuppressingSlidingDownLadder()
      Overrides:
      isSuppressingSlidingDownLadder in class LivingEntity
    • canSpawnSprintParticle

      public boolean canSpawnSprintParticle()
      Overrides:
      canSpawnSprintParticle in class Entity
    • sendRidingJump

      protected void sendRidingJump()
    • sendOpenInventory

      public void sendOpenInventory()
    • getStats

      public StatsCounter getStats()
    • getRecipeBook

      public ClientRecipeBook getRecipeBook()
    • removeRecipeHighlight

      public void removeRecipeHighlight(RecipeHolder<?> pRecipe)
    • getPermissionLevel

      public int getPermissionLevel()
      Overrides:
      getPermissionLevel in class Entity
    • setPermissionLevel

      public void setPermissionLevel(int pPermissionLevel)
    • displayClientMessage

      public void displayClientMessage(Component pChatComponent, boolean pActionBar)
      Overrides:
      displayClientMessage in class Player
    • moveTowardsClosestSpace

      private void moveTowardsClosestSpace(double pX, double pZ)
    • suffocatesAt

      private boolean suffocatesAt(BlockPos pPos)
    • setExperienceValues

      public void setExperienceValues(float pCurrentXP, int pMaxXP, int pLevel)
      Sets the current XP, total XP, and level number.
    • sendSystemMessage

      public void sendSystemMessage(Component pComponent)
      Specified by:
      sendSystemMessage in interface CommandSource
      Overrides:
      sendSystemMessage in class Entity
    • handleEntityEvent

      public void handleEntityEvent(byte pId)
      Handler for
      invalid reference
      World#setEntityState
      Overrides:
      handleEntityEvent in class Player
    • setShowDeathScreen

      public void setShowDeathScreen(boolean pShow)
    • shouldShowDeathScreen

      public boolean shouldShowDeathScreen()
    • setDoLimitedCrafting

      public void setDoLimitedCrafting(boolean pDoLimitedCrafting)
    • getDoLimitedCrafting

      public boolean getDoLimitedCrafting()
    • playSound

      public void playSound(SoundEvent pSound, float pVolume, float pPitch)
      Overrides:
      playSound in class Player
    • playNotifySound

      public void playNotifySound(SoundEvent pSound, SoundSource pSource, float pVolume, float pPitch)
      Overrides:
      playNotifySound in class Player
    • isEffectiveAi

      public boolean isEffectiveAi()
      Overrides:
      isEffectiveAi in class Entity
    • startUsingItem

      public void startUsingItem(InteractionHand pHand)
      Overrides:
      startUsingItem in class LivingEntity
    • isUsingItem

      public boolean isUsingItem()
      Overrides:
      isUsingItem in class LivingEntity
    • stopUsingItem

      public void stopUsingItem()
      Overrides:
      stopUsingItem in class LivingEntity
    • getUsedItemHand

      public InteractionHand getUsedItemHand()
      Overrides:
      getUsedItemHand in class LivingEntity
    • onSyncedDataUpdated

      public void onSyncedDataUpdated(EntityDataAccessor<?> pKey)
      Specified by:
      onSyncedDataUpdated in interface SyncedDataHolder
      Overrides:
      onSyncedDataUpdated in class LivingEntity
    • jumpableVehicle

      @Nullable public PlayerRideableJumping jumpableVehicle()
    • getJumpRidingScale

      public float getJumpRidingScale()
    • isTextFilteringEnabled

      public boolean isTextFilteringEnabled()
      Overrides:
      isTextFilteringEnabled in class Player
    • openTextEdit

      public void openTextEdit(SignBlockEntity pSignEntity, boolean pIsFrontText)
      Overrides:
      openTextEdit in class Player
    • openMinecartCommandBlock

      public void openMinecartCommandBlock(BaseCommandBlock pCommandBlock)
      Overrides:
      openMinecartCommandBlock in class Player
    • openCommandBlock

      public void openCommandBlock(CommandBlockEntity pCommandBlock)
      Overrides:
      openCommandBlock in class Player
    • openStructureBlock

      public void openStructureBlock(StructureBlockEntity pStructure)
      Overrides:
      openStructureBlock in class Player
    • openJigsawBlock

      public void openJigsawBlock(JigsawBlockEntity pJigsawBlockEntity)
      Overrides:
      openJigsawBlock in class Player
    • openItemGui

      public void openItemGui(ItemStack pStack, InteractionHand pHand)
      Overrides:
      openItemGui in class Player
    • crit

      public void crit(Entity pEntityHit)
      Called when the entity is dealt a critical hit.
      Overrides:
      crit in class Player
    • magicCrit

      public void magicCrit(Entity pEntityHit)
      Called when the entity hit is dealt extra melee damage due to an enchantment.
      Overrides:
      magicCrit in class Player
    • isShiftKeyDown

      public boolean isShiftKeyDown()
      Overrides:
      isShiftKeyDown in class Entity
    • isCrouching

      public boolean isCrouching()
      Overrides:
      isCrouching in class Entity
    • isMovingSlowly

      public boolean isMovingSlowly()
    • serverAiStep

      public void serverAiStep()
      Overrides:
      serverAiStep in class Player
    • isControlledCamera

      protected boolean isControlledCamera()
    • resetPos

      public void resetPos()
    • aiStep

      public void aiStep()
      Overrides:
      aiStep in class Player
    • getActivePortalLocalTransition

      public Portal.Transition getActivePortalLocalTransition()
    • tickDeath

      protected void tickDeath()
      Overrides:
      tickDeath in class LivingEntity
    • handleConfusionTransitionEffect

      private void handleConfusionTransitionEffect(boolean pUseConfusion)
    • rideTick

      public void rideTick()
      Overrides:
      rideTick in class Player
    • isHandsBusy

      public boolean isHandsBusy()
    • removeEffectNoUpdate

      @Nullable public MobEffectInstance removeEffectNoUpdate(Holder<MobEffect> pEffect)
      Overrides:
      removeEffectNoUpdate in class LivingEntity
    • move

      public void move(MoverType pType, Vec3 pPos)
      Overrides:
      move in class Entity
    • isAutoJumpEnabled

      public boolean isAutoJumpEnabled()
    • updateAutoJump

      protected void updateAutoJump(float pMovementX, float pMovementZ)
    • isHorizontalCollisionMinor

      protected boolean isHorizontalCollisionMinor(Vec3 pDeltaMovement)
      Overrides:
      isHorizontalCollisionMinor in class Entity
    • canAutoJump

      private boolean canAutoJump()
    • isMoving

      private boolean isMoving()
    • canStartSprinting

      private boolean canStartSprinting()
    • vehicleCanSprint

      private boolean vehicleCanSprint(Entity pVehicle)
    • hasEnoughImpulseToStartSprinting

      private boolean hasEnoughImpulseToStartSprinting()
    • hasEnoughFoodToStartSprinting

      private boolean hasEnoughFoodToStartSprinting()
    • getWaterVision

      public float getWaterVision()
    • onGameModeChanged

      public void onGameModeChanged(GameType pGameMode)
    • isUnderWater

      public boolean isUnderWater()
      Overrides:
      isUnderWater in class Entity
    • updateIsUnderwater

      protected boolean updateIsUnderwater()
      Overrides:
      updateIsUnderwater in class Player
    • getRopeHoldPosition

      public Vec3 getRopeHoldPosition(float pPartialTick)
      Overrides:
      getRopeHoldPosition in class Player
    • updateTutorialInventoryAction

      public void updateTutorialInventoryAction(ItemStack pCarried, ItemStack pClicked, ClickAction pAction)
      Overrides:
      updateTutorialInventoryAction in class Player
    • getVisualRotationYInDegrees

      public float getVisualRotationYInDegrees()
      Overrides:
      getVisualRotationYInDegrees in class LivingEntity