Class PlayerEntity

All Implemented Interfaces:
CommandOutput, Nameable
Direct Known Subclasses:
AbstractClientPlayerEntity, ServerPlayerEntity

public abstract class PlayerEntity
extends LivingEntity
  • Field Details

    • STANDING_DIMENSIONS

      public static final EntityDimensions STANDING_DIMENSIONS
    • POSE_DIMENSIONS

      private static final Map<EntityPose,​EntityDimensions> POSE_DIMENSIONS
    • ABSORPTION_AMOUNT

      private static final TrackedData<Float> ABSORPTION_AMOUNT
    • SCORE

      private static final TrackedData<Integer> SCORE
    • PLAYER_MODEL_PARTS

      protected static final TrackedData<Byte> PLAYER_MODEL_PARTS
    • MAIN_ARM

      protected static final TrackedData<Byte> MAIN_ARM
    • LEFT_SHOULDER_ENTITY

      protected static final TrackedData<CompoundTag> LEFT_SHOULDER_ENTITY
    • RIGHT_SHOULDER_ENTITY

      protected static final TrackedData<CompoundTag> RIGHT_SHOULDER_ENTITY
    • shoulderEntityAddedTime

      private long shoulderEntityAddedTime
    • inventory

      public final PlayerInventory inventory
    • enderChestInventory

      protected EnderChestInventory enderChestInventory
    • playerScreenHandler

      public final PlayerScreenHandler playerScreenHandler
    • currentScreenHandler

      public ScreenHandler currentScreenHandler
    • hungerManager

      protected HungerManager hungerManager
    • abilityResyncCountdown

      protected int abilityResyncCountdown
    • prevStrideDistance

      public float prevStrideDistance
    • strideDistance

      public float strideDistance
    • experiencePickUpDelay

      public int experiencePickUpDelay
    • prevCapeX

      public double prevCapeX
    • prevCapeY

      public double prevCapeY
    • prevCapeZ

      public double prevCapeZ
    • capeX

      public double capeX
    • capeY

      public double capeY
    • capeZ

      public double capeZ
    • sleepTimer

      private int sleepTimer
    • isSubmergedInWater

      protected boolean isSubmergedInWater
    • abilities

      public final PlayerAbilities abilities
    • experienceLevel

      public int experienceLevel
    • totalExperience

      public int totalExperience
    • experienceProgress

      public float experienceProgress
    • enchantmentTableSeed

      protected int enchantmentTableSeed
    • field_7509

      protected final float field_7509
      See Also:
      Constant Field Values
    • lastPlayedLevelUpSoundTime

      private int lastPlayedLevelUpSoundTime
    • gameProfile

      private final com.mojang.authlib.GameProfile gameProfile
    • reducedDebugInfo

      @Environment(CLIENT) private boolean reducedDebugInfo
    • selectedItem

      private ItemStack selectedItem
    • itemCooldownManager

      private final ItemCooldownManager itemCooldownManager
    • fishHook

      @Nullable public FishingBobberEntity fishHook
  • Constructor Details

    • PlayerEntity

      public PlayerEntity​(World world, BlockPos pos, float yaw, com.mojang.authlib.GameProfile profile)
  • Method Details

    • isBlockBreakingRestricted

      public boolean isBlockBreakingRestricted​(World world, BlockPos pos, GameMode gameMode)
    • createPlayerAttributes

      public static DefaultAttributeContainer.Builder createPlayerAttributes()
    • initDataTracker

      protected void initDataTracker()
      Overrides:
      initDataTracker in class LivingEntity
    • tick

      public void tick()
      Overrides:
      tick in class LivingEntity
    • shouldCancelInteraction

      public boolean shouldCancelInteraction()
    • shouldDismount

      protected boolean shouldDismount()
    • clipAtLedge

      protected boolean clipAtLedge()
    • updateWaterSubmersionState

      protected boolean updateWaterSubmersionState()
    • updateTurtleHelmet

      private void updateTurtleHelmet()
    • createCooldownManager

      protected ItemCooldownManager createCooldownManager()
    • updateCapeAngles

      private void updateCapeAngles()
    • updateSize

      protected void updateSize()
    • getMaxNetherPortalTime

      public int getMaxNetherPortalTime()
      Overrides:
      getMaxNetherPortalTime in class Entity
    • getSwimSound

      protected SoundEvent getSwimSound()
      Overrides:
      getSwimSound in class Entity
    • getSplashSound

      protected SoundEvent getSplashSound()
      Overrides:
      getSplashSound in class Entity
    • getHighSpeedSplashSound

      protected SoundEvent getHighSpeedSplashSound()
      Overrides:
      getHighSpeedSplashSound in class Entity
    • getDefaultNetherPortalCooldown

      public int getDefaultNetherPortalCooldown()
      Overrides:
      getDefaultNetherPortalCooldown in class Entity
    • playSound

      public void playSound​(SoundEvent sound, float volume, float pitch)
      Overrides:
      playSound in class Entity
    • playSound

      public void playSound​(SoundEvent event, SoundCategory category, float volume, float pitch)
    • getSoundCategory

      public SoundCategory getSoundCategory()
      Overrides:
      getSoundCategory in class Entity
    • getBurningDuration

      protected int getBurningDuration()
      Overrides:
      getBurningDuration in class Entity
    • handleStatus

      @Environment(CLIENT) public void handleStatus​(byte status)
      Overrides:
      handleStatus in class LivingEntity
    • spawnParticles

      @Environment(CLIENT) private void spawnParticles​(ParticleEffect parameters)
    • closeHandledScreen

      protected void closeHandledScreen()
    • tickRiding

      public void tickRiding()
      Overrides:
      tickRiding in class LivingEntity
    • afterSpawn

      @Environment(CLIENT) public void afterSpawn()
      Overrides:
      afterSpawn in class Entity
    • tickNewAi

      protected void tickNewAi()
      Overrides:
      tickNewAi in class LivingEntity
    • tickMovement

      public void tickMovement()
      Overrides:
      tickMovement in class LivingEntity
    • updateShoulderEntity

      private void updateShoulderEntity​(@Nullable CompoundTag compoundTag)
    • collideWithEntity

      private void collideWithEntity​(Entity entity)
    • getScore

      public int getScore()
    • setScore

      public void setScore​(int score)
    • addScore

      public void addScore​(int score)
    • onDeath

      public void onDeath​(DamageSource source)
      Overrides:
      onDeath in class LivingEntity
    • dropInventory

      protected void dropInventory()
      Overrides:
      dropInventory in class LivingEntity
    • vanishCursedItems

      protected void vanishCursedItems()
    • getHurtSound

      protected SoundEvent getHurtSound​(DamageSource source)
      Overrides:
      getHurtSound in class LivingEntity
    • getDeathSound

      protected SoundEvent getDeathSound()
      Overrides:
      getDeathSound in class LivingEntity
    • dropSelectedItem

      public boolean dropSelectedItem​(boolean dropEntireStack)
    • dropItem

      @Nullable public ItemEntity dropItem​(ItemStack stack, boolean retainOwnership)
    • dropItem

      @Nullable public ItemEntity dropItem​(ItemStack stack, boolean throwRandomly, boolean retainOwnership)
      Parameters:
      throwRandomly - If true, the item will be thrown in a random direction from the entity regardless of which direction the entity is facing
    • getBlockBreakingSpeed

      public float getBlockBreakingSpeed​(BlockState block)
    • isUsingEffectiveTool

      public boolean isUsingEffectiveTool​(BlockState block)
    • readCustomDataFromTag

      public void readCustomDataFromTag​(CompoundTag tag)
      Overrides:
      readCustomDataFromTag in class LivingEntity
    • writeCustomDataToTag

      public void writeCustomDataToTag​(CompoundTag tag)
      Overrides:
      writeCustomDataToTag in class LivingEntity
    • isInvulnerableTo

      public boolean isInvulnerableTo​(DamageSource damageSource)
      Overrides:
      isInvulnerableTo in class Entity
    • damage

      public boolean damage​(DamageSource source, float amount)
      Overrides:
      damage in class LivingEntity
    • takeShieldHit

      protected void takeShieldHit​(LivingEntity attacker)
      Overrides:
      takeShieldHit in class LivingEntity
    • shouldDamagePlayer

      public boolean shouldDamagePlayer​(PlayerEntity player)
    • damageArmor

      protected void damageArmor​(DamageSource source, float amount)
      Overrides:
      damageArmor in class LivingEntity
    • damageShield

      protected void damageShield​(float amount)
      Overrides:
      damageShield in class LivingEntity
    • applyDamage

      protected void applyDamage​(DamageSource source, float amount)
      Overrides:
      applyDamage in class LivingEntity
    • isOnSoulSpeedBlock

      protected boolean isOnSoulSpeedBlock()
      Overrides:
      isOnSoulSpeedBlock in class LivingEntity
    • openEditSignScreen

      public void openEditSignScreen​(SignBlockEntity sign)
    • openCommandBlockMinecartScreen

      public void openCommandBlockMinecartScreen​(CommandBlockExecutor commandBlockExecutor)
    • openCommandBlockScreen

      public void openCommandBlockScreen​(CommandBlockBlockEntity commandBlock)
    • openStructureBlockScreen

      public void openStructureBlockScreen​(StructureBlockBlockEntity structureBlock)
    • openJigsawScreen

      public void openJigsawScreen​(JigsawBlockEntity jigsaw)
    • openHorseInventory

      public void openHorseInventory​(HorseBaseEntity horse, Inventory inventory)
    • openHandledScreen

      public OptionalInt openHandledScreen​(@Nullable NamedScreenHandlerFactory factory)
    • sendTradeOffers

      public void sendTradeOffers​(int syncId, TradeOfferList offers, int levelProgress, int experience, boolean leveled, boolean refreshable)
    • openEditBookScreen

      public void openEditBookScreen​(ItemStack book, Hand hand)
    • interact

      public ActionResult interact​(Entity entity, Hand hand)
    • getHeightOffset

      public double getHeightOffset()
      Overrides:
      getHeightOffset in class Entity
    • method_29239

      public void method_29239()
      Overrides:
      method_29239 in class Entity
    • isImmobile

      protected boolean isImmobile()
      Overrides:
      isImmobile in class LivingEntity
    • method_29920

      public boolean method_29920()
      Overrides:
      method_29920 in class LivingEntity
    • adjustMovementForSneaking

      protected Vec3d adjustMovementForSneaking​(Vec3d movement, MovementType type)
      Overrides:
      adjustMovementForSneaking in class Entity
    • method_30263

      private boolean method_30263()
    • attack

      public void attack​(Entity target)
    • attackLivingEntity

      protected void attackLivingEntity​(LivingEntity target)
      Overrides:
      attackLivingEntity in class LivingEntity
    • disableShield

      public void disableShield​(boolean sprinting)
    • addCritParticles

      public void addCritParticles​(Entity target)
    • addEnchantedHitParticles

      public void addEnchantedHitParticles​(Entity target)
    • spawnSweepAttackParticles

      public void spawnSweepAttackParticles()
    • requestRespawn

      @Environment(CLIENT) public void requestRespawn()
    • remove

      public void remove()
      Overrides:
      remove in class Entity
    • isMainPlayer

      public boolean isMainPlayer()
    • getGameProfile

      public com.mojang.authlib.GameProfile getGameProfile()
    • trySleep

      public com.mojang.datafixers.util.Either<PlayerEntity.SleepFailureReason,​Unit> trySleep​(BlockPos pos)
    • wakeUp

      public void wakeUp​(boolean bool, boolean updateSleepingPlayers)
    • wakeUp

      public void wakeUp()
      Overrides:
      wakeUp in class LivingEntity
    • findRespawnPosition

      public static Optional<Vec3d> findRespawnPosition​(ServerWorld world, BlockPos pos, float float2, boolean bool, boolean bool2)
    • isSleepingLongEnough

      public boolean isSleepingLongEnough()
    • getSleepTimer

      public int getSleepTimer()
    • sendMessage

      public void sendMessage​(Text message, boolean actionBar)
    • incrementStat

      public void incrementStat​(Identifier stat)
    • increaseStat

      public void increaseStat​(Identifier stat, int amount)
    • incrementStat

      public void incrementStat​(Stat<?> stat)
    • increaseStat

      public void increaseStat​(Stat<?> stat, int amount)
    • resetStat

      public void resetStat​(Stat<?> stat)
    • unlockRecipes

      public int unlockRecipes​(Collection<Recipe<?>> recipes)
    • unlockRecipes

      public void unlockRecipes​(Identifier[] ids)
    • lockRecipes

      public int lockRecipes​(Collection<Recipe<?>> recipes)
    • jump

      public void jump()
      Overrides:
      jump in class LivingEntity
    • travel

      public void travel​(Vec3d movementInput)
      Overrides:
      travel in class LivingEntity
    • updateSwimming

      public void updateSwimming()
      Overrides:
      updateSwimming in class Entity
    • doesNotSuffocate

      protected boolean doesNotSuffocate​(BlockPos pos)
    • getMovementSpeed

      public float getMovementSpeed()
      Overrides:
      getMovementSpeed in class LivingEntity
    • increaseTravelMotionStats

      public void increaseTravelMotionStats​(double dx, double dy, double dz)
    • increaseRidingMotionStats

      private void increaseRidingMotionStats​(double dx, double dy, double dz)
    • handleFallDamage

      public boolean handleFallDamage​(float fallDistance, float damageMultiplier)
      Overrides:
      handleFallDamage in class LivingEntity
    • checkFallFlying

      public boolean checkFallFlying()
    • startFallFlying

      public void startFallFlying()
    • stopFallFlying

      public void stopFallFlying()
    • onSwimmingStart

      protected void onSwimmingStart()
      Overrides:
      onSwimmingStart in class Entity
    • getFallSound

      protected SoundEvent getFallSound​(int distance)
      Overrides:
      getFallSound in class LivingEntity
    • onKilledOther

      public void onKilledOther​(ServerWorld serverWorld, LivingEntity livingEntity)
      Overrides:
      onKilledOther in class Entity
    • slowMovement

      public void slowMovement​(BlockState state, Vec3d multiplier)
      Overrides:
      slowMovement in class Entity
    • addExperience

      public void addExperience​(int experience)
    • getEnchantmentTableSeed

      public int getEnchantmentTableSeed()
    • applyEnchantmentCosts

      public void applyEnchantmentCosts​(ItemStack enchantedItem, int experienceLevels)
    • addExperienceLevels

      public void addExperienceLevels​(int levels)
    • getNextLevelExperience

      public int getNextLevelExperience()
    • addExhaustion

      public void addExhaustion​(float exhaustion)
    • getHungerManager

      public HungerManager getHungerManager()
    • canConsume

      public boolean canConsume​(boolean ignoreHunger)
    • canFoodHeal

      public boolean canFoodHeal()
    • canModifyBlocks

      public boolean canModifyBlocks()
    • canPlaceOn

      public boolean canPlaceOn​(BlockPos pos, Direction facing, ItemStack stack)
    • getCurrentExperience

      protected int getCurrentExperience​(PlayerEntity player)
      Overrides:
      getCurrentExperience in class LivingEntity
    • shouldAlwaysDropXp

      protected boolean shouldAlwaysDropXp()
      Overrides:
      shouldAlwaysDropXp in class LivingEntity
    • shouldRenderName

      @Environment(CLIENT) public boolean shouldRenderName()
      Overrides:
      shouldRenderName in class LivingEntity
    • canClimb

      protected boolean canClimb()
      Overrides:
      canClimb in class Entity
    • sendAbilitiesUpdate

      public void sendAbilitiesUpdate()
    • setGameMode

      public void setGameMode​(GameMode gameMode)
    • getName

      public Text getName()
      Specified by:
      getName in interface Nameable
      Overrides:
      getName in class Entity
    • getEnderChestInventory

      public EnderChestInventory getEnderChestInventory()
    • getEquippedStack

      public ItemStack getEquippedStack​(EquipmentSlot slot)
      Specified by:
      getEquippedStack in class LivingEntity
    • equipStack

      public void equipStack​(EquipmentSlot slot, ItemStack stack)
      Specified by:
      equipStack in class LivingEntity
    • giveItemStack

      public boolean giveItemStack​(ItemStack stack)
    • getItemsHand

      public Iterable<ItemStack> getItemsHand()
      Overrides:
      getItemsHand in class Entity
    • getArmorItems

      public Iterable<ItemStack> getArmorItems()
      Specified by:
      getArmorItems in class LivingEntity
    • addShoulderEntity

      public boolean addShoulderEntity​(CompoundTag tag)
    • dropShoulderEntities

      protected void dropShoulderEntities()
    • dropShoulderEntity

      private void dropShoulderEntity​(CompoundTag entityNbt)
    • isSpectator

      public abstract boolean isSpectator()
      Overrides:
      isSpectator in class Entity
    • isSwimming

      public boolean isSwimming()
      Overrides:
      isSwimming in class Entity
    • isCreative

      public abstract boolean isCreative()
    • canFly

      public boolean canFly()
      Overrides:
      canFly in class Entity
    • getScoreboard

      public Scoreboard getScoreboard()
    • getDisplayName

      public Text getDisplayName()
      Specified by:
      getDisplayName in interface Nameable
      Overrides:
      getDisplayName in class Entity
    • addTellClickEvent

      private MutableText addTellClickEvent​(MutableText component)
    • getEntityName

      public String getEntityName()
      Overrides:
      getEntityName in class Entity
    • getActiveEyeHeight

      public float getActiveEyeHeight​(EntityPose pose, EntityDimensions dimensions)
      Overrides:
      getActiveEyeHeight in class LivingEntity
    • setAbsorptionAmount

      public void setAbsorptionAmount​(float amount)
      Overrides:
      setAbsorptionAmount in class LivingEntity
    • getAbsorptionAmount

      public float getAbsorptionAmount()
      Overrides:
      getAbsorptionAmount in class LivingEntity
    • getUuidFromProfile

      public static UUID getUuidFromProfile​(com.mojang.authlib.GameProfile profile)
    • getOfflinePlayerUuid

      public static UUID getOfflinePlayerUuid​(String nickname)
    • isPartVisible

      @Environment(CLIENT) public boolean isPartVisible​(PlayerModelPart modelPart)
    • equip

      public boolean equip​(int slot, ItemStack item)
      Overrides:
      equip in class Entity
    • getReducedDebugInfo

      @Environment(CLIENT) public boolean getReducedDebugInfo()
    • setReducedDebugInfo

      @Environment(CLIENT) public void setReducedDebugInfo​(boolean reducedDebugInfo)
    • setFireTicks

      public void setFireTicks​(int ticks)
      Overrides:
      setFireTicks in class Entity
    • getMainArm

      public Arm getMainArm()
      Specified by:
      getMainArm in class LivingEntity
    • setMainArm

      public void setMainArm​(Arm arm)
    • getShoulderEntityLeft

      public CompoundTag getShoulderEntityLeft()
    • setShoulderEntityLeft

      protected void setShoulderEntityLeft​(CompoundTag entityTag)
    • getShoulderEntityRight

      public CompoundTag getShoulderEntityRight()
    • setShoulderEntityRight

      protected void setShoulderEntityRight​(CompoundTag entityTag)
    • getAttackCooldownProgressPerTick

      public float getAttackCooldownProgressPerTick()
    • getAttackCooldownProgress

      public float getAttackCooldownProgress​(float baseTime)
    • resetLastAttackedTicks

      public void resetLastAttackedTicks()
    • getItemCooldownManager

      public ItemCooldownManager getItemCooldownManager()
    • getVelocityMultiplier

      protected float getVelocityMultiplier()
      Overrides:
      getVelocityMultiplier in class LivingEntity
    • getLuck

      public float getLuck()
    • isCreativeLevelTwoOp

      public boolean isCreativeLevelTwoOp()
    • canEquip

      public boolean canEquip​(ItemStack stack)
      Overrides:
      canEquip in class LivingEntity
    • getDimensions

      public EntityDimensions getDimensions​(EntityPose pose)
      Overrides:
      getDimensions in class LivingEntity
    • getPoses

      public ImmutableList<EntityPose> getPoses()
      Overrides:
      getPoses in class LivingEntity
    • getArrowType

      public ItemStack getArrowType​(ItemStack stack)
      Overrides:
      getArrowType in class LivingEntity
    • eatFood

      public ItemStack eatFood​(World world, ItemStack stack)
      Overrides:
      eatFood in class LivingEntity
    • method_29500

      protected boolean method_29500​(BlockState blockState)
      Overrides:
      method_29500 in class LivingEntity
    • method_30951

      @Environment(CLIENT) public Vec3d method_30951​(float float2)
      Overrides:
      method_30951 in class Entity