Class LocalPlayer

All Implemented Interfaces:
DataComponentGetter, SyncedDataHolder, Attackable, EntityAccess, UniquelyIdentifyable, Nameable, ScoreHolder, Waypoint, WaypointTransmitter, IAttachmentHolder, IEntityExtension, ILivingEntityExtension, IPlayerExtension

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:
    • USING_ITEM_SPEED_FACTOR

      public static final float USING_ITEM_SPEED_FACTOR
      See Also:
    • connection

      public final ClientPacketListener connection
    • stats

      private final StatsCounter stats
    • recipeBook

      private final ClientRecipeBook recipeBook
    • dropSpamThrottler

      private final TickThrottler dropSpamThrottler
    • 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
    • yLast

      private double yLast
    • 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
    • lastHorizontalCollision

      private boolean lastHorizontalCollision
    • crouching

      private boolean crouching
    • 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 ClientInput input
    • lastSentInput

      private Input lastSentInput
    • minecraft

      protected final Minecraft minecraft
    • sprintTriggerTime

      protected int sprintTriggerTime
    • experienceDisplayStartTick

      public int experienceDisplayStartTick
    • yBob

      public float yBob
    • xBob

      public float xBob
    • yBobO

      public float yBobO
    • xBobO

      public float xBobO
    • jumpRidingTicks

      private int jumpRidingTicks
    • jumpRidingScale

      private float jumpRidingScale
    • portalEffectIntensity

      public float portalEffectIntensity
    • oPortalEffectIntensity

      public float oPortalEffectIntensity
    • 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

    • 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
    • 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(RecipeDisplayId pRecipe)
    • getPermissionLevel

      public int getPermissionLevel()
      Overrides:
      getPermissionLevel in class Player
    • 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.
    • 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
    • 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
    • openTestBlock

      public void openTestBlock(TestBlockEntity pTestBlockEntity)
      Overrides:
      openTestBlock in class Player
    • openTestInstanceBlock

      public void openTestInstanceBlock(TestInstanceBlockEntity pTestInstanceBlockEntity)
      Overrides:
      openTestInstanceBlock in class Player
    • openJigsawBlock

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

      public void openDialog(Holder<Dialog> pDialog)
      Overrides:
      openDialog 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)
      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()
    • applyInput

      public void applyInput()
      Overrides:
      applyInput in class LivingEntity
    • modifyInput

      private Vec2 modifyInput(Vec2 pMoveVector)
    • modifyInputSpeedForSquareMovement

      private static Vec2 modifyInputSpeedForSquareMovement(Vec2 pMoveVector)
    • distanceToUnitSquare

      private static float distanceToUnitSquare(Vec2 pMoveVector)
    • isControlledCamera

      protected boolean isControlledCamera()
    • resetPos

      public void resetPos()
    • aiStep

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

      private boolean shouldStopRunSprinting()
    • shouldStopSwimSprinting

      private boolean shouldStopSwimSprinting()
    • hasBlindness

      private boolean hasBlindness()
    • getActivePortalLocalTransition

      public Portal.Transition getActivePortalLocalTransition()
    • tickDeath

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

      private void handlePortalTransitionEffect(boolean pInPortal)
    • rideTick

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

      public boolean isHandsBusy()
    • move

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

      public boolean isAutoJumpEnabled()
    • shouldRotateWithMinecart

      public boolean shouldRotateWithMinecart()
      Overrides:
      shouldRotateWithMinecart in class Player
    • 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)
    • hasEnoughFoodToSprint

      private boolean hasEnoughFoodToSprint()
    • 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
    • handleCreativeModeItemDrop

      public void handleCreativeModeItemDrop(ItemStack pStack)
      Overrides:
      handleCreativeModeItemDrop in class Player
    • canDropItems

      public boolean canDropItems()
      Overrides:
      canDropItems in class Player
    • getDropSpamThrottler

      public TickThrottler getDropSpamThrottler()
    • getLastSentInput

      public Input getLastSentInput()