Package net.minecraft.entity
Class LivingEntity
java.lang.Object
net.minecraft.entity.Entity
net.minecraft.entity.LivingEntity
- All Implemented Interfaces:
CommandOutput
,Nameable
- Direct Known Subclasses:
ArmorStandEntity
,MobEntity
,PlayerEntity
public abstract class LivingEntity extends Entity
Represents an entity which has a health value and can receive damage.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.entity.Entity
Entity.PositionUpdater
-
Field Summary
Fields inherited from class net.minecraft.entity.Entity
age, chunkX, chunkY, chunkZ, dataTracker, distanceTraveled, fallDistance, field_25599, firstUpdate, FLAGS, fluidHeight, glowing, horizontalCollision, horizontalSpeed, ignoreCameraFrustum, inanimate, inNetherPortal, lastNetherPortalPosition, lastRenderX, lastRenderY, lastRenderZ, LOGGER, movementMultiplier, netherPortalTime, noClip, onGround, pitch, POSE, prevHorizontalSpeed, prevPitch, prevX, prevY, prevYaw, prevZ, pushSpeedReduction, random, removed, ridingCooldown, stepHeight, submergedInWater, teleporting, timeUntilRegen, touchingWater, updateNeeded, uuid, uuidString, velocityDirty, velocityModified, verticalCollision, world, yaw
Fields inherited from interface net.minecraft.server.command.CommandOutput
DUMMY
-
Constructor Summary
Constructors Modifier Constructor Description protected
LivingEntity(EntityType<? extends LivingEntity> type, World world)
-
Method Summary
Methods inherited from class net.minecraft.entity.Entity
addPassenger, addScoreboardTag, addVelocity, adjustMovementForCollisions, adjustMovementForCollisions, adjustMovementForPiston, adjustMovementForSneaking, adjustSingleAxisMovementForCollisions, afterSpawn, applyMirror, applyRotation, bypassesLandingEffects, bypassesSteppingEffects, calculateBoundsForPose, calculateDimensions, calculateNextStepSoundDistance, canAddPassenger, canAvoidTraps, canBeSpectated, canClimb, canExplosionDestroyBlock, canFly, canStartRiding, canUsePortals, changeLookDirection, checkBlockCollision, checkDespawn, checkWaterState, collidesWith, copyFrom, copyPositionAndRotation, dealDamage, detach, distanceTo, doesNotCollide, doesRenderOnFire, dropItem, dropItem, dropStack, dropStack, entityDataRequiresOperator, equals, equip, extinguish, fromTag, getAir, getBlockPos, getBodyY, getBoundingBox, getBrightnessAtEyes, getBurningDuration, getCameraPosVec, getCommandSource, getCustomName, getDataTracker, getDefaultName, getDefaultNetherPortalCooldown, getDisplayName, getEffectiveExplosionResistance, getEntityId, getEntityName, getEntityWorld, getEyeHeight, getEyeY, getFireTicks, getFlag, getFluidHeight, getHeight, getHeightOffset, getHighSpeedSplashSound, getHorizontalFacing, getHoverEvent, getItemsEquipped, getItemsHand, getJumpVelocityMultiplier, getLandingBlockState, getLandingPos, getMaxAir, getMaxNetherPortalTime, getMountedHeightOffset, getMovementDirection, getName, getOppositeRotationVector, getOppositeRotationVector, getParticleX, getParticleZ, getPassengerDismountOffset, getPassengerList, getPassengersDeep, getPermissionLevel, getPistonBehavior, getPitch, getPos, getPose, getPrimaryPassenger, getRandomBodyY, getRenderDistanceMultiplier, getRootVehicle, getRotationClient, getRotationVec, getRotationVecClient, getRotationVector, getRotationVector, getSafeFallDistance, getSavedEntityId, getScoreboardTags, getScoreboardTeam, getServer, getSoundCategory, getSplashSound, getStandingEyeHeight, getSwimSound, getTargetingMargin, getTeamColorValue, getTeleportTarget, getTrackedPosition, getType, getUuid, getUuidAsString, getVehicle, getVelocity, getVelocityAffectingPos, getWidth, getX, getY, getZ, handleAttack, hasCustomName, hashCode, hasNetherPortalCooldown, hasNoGravity, hasPassenger, hasPassengerDeep, hasPassengers, hasPassengerType, hasPermissionLevel, hasPlayerRider, hasVehicle, hasWings, interact, interactAt, isAttackable, isChunkPosUpdateRequested, isCollidable, isConnectedThroughVehicle, isCustomNameVisible, isDescending, isFireImmune, isGlowing, isImmuneToExplosion, isInLava, isInRange, isInsideWaterOrBubbleColumn, isInSneakingPose, isInvisible, isInvisibleTo, isInvulnerable, isInvulnerableTo, isLiving, isLogicalSideForUpdatingMovement, isOnFire, isOnGround, isPartOf, isSilent, isSneaking, isSneaky, isSpectator, isSprinting, isSubmergedIn, isSubmergedInWater, isSwimming, isTeammate, isTeamPlayer, isTouchingWater, isTouchingWaterOrRain, isWet, method_29239, method_29241, method_29919, method_30076, method_30330, method_30632, method_30634, method_30950, method_30951, method_31166, move, moveToBoundingBoxCenter, moveToWorld, offsetX, offsetZ, onBlockCollision, onBubbleColumnCollision, onBubbleColumnSurfaceCollision, onKilledOther, onPassengerLookAround, onPlayerCollision, onStartedTrackingBy, onStoppedTrackingBy, onStruckByLightning, onSwimmingStart, playFlySound, playSound, playStepSound, playSwimSound, populateCrashReport, pushOutOfBlocks, raycast, refreshPosition, refreshPositionAfterTeleport, refreshPositionAfterTeleport, refreshPositionAndAngles, refreshPositionAndAngles, remove, removeAllPassengers, removePassenger, removeScoreboardTag, requestTeleport, resetNetherPortalCooldown, resetPosition, saveSelfToTag, saveToTag, sendSystemMessage, setAir, setBoundingBox, setCustomName, setCustomNameVisible, setEntityId, setFireTicks, setFlag, setGlowing, setInNetherPortal, setInvisible, setInvulnerable, setNoGravity, setOnFireFor, setOnFireFromLava, setPos, setPose, setRenderDistanceMultiplier, setRotation, setSilent, setSneaking, setSwimming, setUuid, setVelocity, setVelocity, setVelocityClient, setWorld, shouldBroadcastConsoleToOps, shouldLeaveSwimmingPose, shouldReceiveFeedback, shouldRender, shouldRender, shouldSetPositionOnLoad, shouldSpawnSprintingParticles, shouldTrackOutput, slowMovement, spawnSprintingParticles, squaredDistanceTo, squaredDistanceTo, squaredDistanceTo, squaredHorizontalLength, startRiding, startRiding, streamPassengersRecursively, teleport, teleportRequested, tickNetherPortal, tickNetherPortalCooldown, toListTag, toListTag, toString, toTag, updateKilledAdvancementCriterion, updateMovementInFluid, updatePassengerForDismount, updatePassengerPosition, updatePosition, updatePositionAndAngles, updateSwimming, updateTrackedPosition, updateTrackedPosition, updateVelocity, updateWaterState, wouldPoseNotCollide
-
Field Details
-
SPRINTING_SPEED_BOOST_ID
-
SOUL_SPEED_BOOST_ID
-
SPRINTING_SPEED_BOOST
-
LIVING_FLAGS
-
HEALTH
-
POTION_SWIRLS_COLOR
-
POTION_SWIRLS_AMBIENT
-
STUCK_ARROW_COUNT
-
STINGER_COUNT
-
SLEEPING_POSITION
-
SLEEPING_DIMENSIONS
-
attributes
-
damageTracker
-
activeStatusEffects
-
equippedHand
-
equippedArmor
-
handSwinging
public boolean handSwinging -
preferredHand
-
handSwingTicks
public int handSwingTicks -
stuckArrowTimer
public int stuckArrowTimer -
stuckStingerTimer
public int stuckStingerTimer -
hurtTime
public int hurtTime -
maxHurtTime
public int maxHurtTime -
knockbackVelocity
public float knockbackVelocity -
deathTime
public int deathTime -
lastHandSwingProgress
public float lastHandSwingProgress -
handSwingProgress
public float handSwingProgress -
lastAttackedTicks
protected int lastAttackedTicks -
lastLimbDistance
public float lastLimbDistance -
limbDistance
public float limbDistance -
limbAngle
public float limbAngle -
defaultMaxHealth
public final int defaultMaxHealth- See Also:
- Constant Field Values
-
randomLargeSeed
public final float randomLargeSeed -
randomSmallSeed
public final float randomSmallSeed -
bodyYaw
public float bodyYaw -
prevBodyYaw
public float prevBodyYaw -
headYaw
public float headYaw -
prevHeadYaw
public float prevHeadYaw -
flyingSpeed
public float flyingSpeed -
attackingPlayer
-
playerHitTimer
protected int playerHitTimer -
dead
protected boolean dead -
despawnCounter
protected int despawnCounter -
prevStepBobbingAmount
protected float prevStepBobbingAmount -
stepBobbingAmount
protected float stepBobbingAmount -
lookDirection
protected float lookDirection -
prevLookDirection
protected float prevLookDirection -
field_6215
protected float field_6215 -
scoreAmount
protected int scoreAmount -
lastDamageTaken
protected float lastDamageTaken -
jumping
protected boolean jumping -
sidewaysSpeed
public float sidewaysSpeed -
upwardSpeed
public float upwardSpeed -
forwardSpeed
public float forwardSpeed -
bodyTrackingIncrements
protected int bodyTrackingIncrements -
serverX
protected double serverX -
serverY
protected double serverY -
serverZ
protected double serverZ -
serverYaw
protected double serverYaw -
serverPitch
protected double serverPitch -
serverHeadYaw
protected double serverHeadYaw -
headTrackingIncrements
protected int headTrackingIncrements -
effectsChanged
private boolean effectsChanged -
attacker
-
lastAttackedTime
private int lastAttackedTime -
attacking
-
lastAttackTime
private int lastAttackTime -
movementSpeed
private float movementSpeed -
jumpingCooldown
private int jumpingCooldown -
absorptionAmount
private float absorptionAmount -
activeItemStack
-
itemUseTimeLeft
protected int itemUseTimeLeft -
roll
protected int roll -
lastBlockPos
-
climbingPos
-
lastDamageSource
-
lastDamageTime
private long lastDamageTime -
riptideTicks
protected int riptideTicks -
leaningPitch
private float leaningPitch -
lastLeaningPitch
private float lastLeaningPitch -
brain
-
-
Constructor Details
-
LivingEntity
-
-
Method Details
-
getBrain
-
createBrainProfile
-
deserializeBrain
-
kill
public void kill() -
canTarget
-
initDataTracker
protected void initDataTracker()- Specified by:
initDataTracker
in classEntity
-
createLivingAttributes
-
fall
protected void fall(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition) -
canBreatheInWater
public boolean canBreatheInWater() -
getLeaningPitch
@Environment(CLIENT) public float getLeaningPitch(float tickDelta) -
baseTick
public void baseTick() -
shouldDisplaySoulSpeedEffects
public boolean shouldDisplaySoulSpeedEffects() -
displaySoulSpeedEffects
protected void displaySoulSpeedEffects() -
isOnSoulSpeedBlock
protected boolean isOnSoulSpeedBlock() -
getVelocityMultiplier
protected float getVelocityMultiplier()- Overrides:
getVelocityMultiplier
in classEntity
-
method_29500
-
removeSoulSpeedBoost
protected void removeSoulSpeedBoost() -
addSoulSpeedBoostIfNeeded
protected void addSoulSpeedBoostIfNeeded() -
applyMovementEffects
-
isBaby
public boolean isBaby() -
getScaleFactor
public float getScaleFactor() -
method_29920
protected boolean method_29920() -
canBeRiddenInWater
public boolean canBeRiddenInWater()- Overrides:
canBeRiddenInWater
in classEntity
-
updatePostDeath
protected void updatePostDeath() -
canDropLootAndXp
protected boolean canDropLootAndXp() -
shouldDropLoot
protected boolean shouldDropLoot() -
getNextAirUnderwater
protected int getNextAirUnderwater(int air) -
getNextAirOnLand
protected int getNextAirOnLand(int air) -
getCurrentExperience
-
shouldAlwaysDropXp
protected boolean shouldAlwaysDropXp() -
getRandom
-
getAttacker
-
getLastAttackedTime
public int getLastAttackedTime() -
setAttacking
-
setAttacker
-
getAttacking
-
getLastAttackTime
public int getLastAttackTime() -
onAttacking
-
getDespawnCounter
public int getDespawnCounter() -
setDespawnCounter
public void setDespawnCounter(int despawnCounter) -
onEquipStack
-
writeCustomDataToTag
- Specified by:
writeCustomDataToTag
in classEntity
-
readCustomDataFromTag
- Specified by:
readCustomDataFromTag
in classEntity
-
tickStatusEffects
protected void tickStatusEffects() -
updatePotionVisibility
protected void updatePotionVisibility() -
getAttackDistanceScalingFactor
-
canTarget
-
isTarget
-
containsOnlyAmbientEffects
-
clearPotionSwirls
protected void clearPotionSwirls() -
clearStatusEffects
public boolean clearStatusEffects() -
getStatusEffects
-
getActiveStatusEffects
-
hasStatusEffect
-
getStatusEffect
-
addStatusEffect
-
canHaveStatusEffect
-
applyStatusEffect
-
isUndead
public boolean isUndead() -
removeStatusEffectInternal
Removes a status effect from this entity without calling any listener.This method does not perform any cleanup or synchronization operation. Under most circumstances, calling
removeStatusEffect(net.minecraft.entity.effect.StatusEffect)
is highly preferable. -
removeStatusEffect
Removes a status effect from this entity.Calling this method will call cleanup methods on the status effect and trigger synchronization of effect particles with watching clients. If this entity is a player, the change in the list of effects will also be synchronized with the corresponding client.
- Returns:
true
if aStatusEffectInstance
with the given type was in effect before the removal.
-
onStatusEffectApplied
-
onStatusEffectUpgraded
-
onStatusEffectRemoved
-
heal
public void heal(float amount) -
getHealth
public float getHealth() -
setHealth
public void setHealth(float health) -
isDead
public boolean isDead() -
damage
-
takeShieldHit
-
knockback
-
tryUseTotem
-
getRecentDamageSource
-
playHurtSound
-
blockedByShield
-
playEquipmentBreakEffects
-
onDeath
-
onKilledBy
Performs secondary effects after this mob has been killed.The default behavior spawns a wither rose if
adversary
is aWitherEntity
.- Parameters:
adversary
- the main adversary responsible for this entity's death
-
drop
-
dropInventory
protected void dropInventory() -
dropXp
protected void dropXp() -
dropEquipment
-
getLootTable
-
dropLoot
-
getLootContextBuilder
-
takeKnockback
public void takeKnockback(float float2, double double2, double double3) -
getHurtSound
-
getDeathSound
-
getFallSound
-
getDrinkSound
-
getEatSound
-
setOnGround
public void setOnGround(boolean onGround)- Overrides:
setOnGround
in classEntity
-
getClimbingPos
-
isClimbing
public boolean isClimbing() -
getBlockState
-
canEnterTrapdoor
-
isAlive
public boolean isAlive() -
handleFallDamage
public boolean handleFallDamage(float fallDistance, float damageMultiplier)- Overrides:
handleFallDamage
in classEntity
-
computeFallDamage
protected int computeFallDamage(float fallDistance, float damageMultiplier) -
playBlockFallSound
protected void playBlockFallSound() -
animateDamage
@Environment(CLIENT) public void animateDamage()- Overrides:
animateDamage
in classEntity
-
getArmor
public int getArmor() -
damageArmor
-
damageShield
protected void damageShield(float amount) -
applyArmorToDamage
-
applyEnchantmentsToDamage
-
applyDamage
-
getDamageTracker
-
getPrimeAdversary
-
getMaxHealth
public final float getMaxHealth() -
getStuckArrowCount
public final int getStuckArrowCount() -
setStuckArrowCount
public final void setStuckArrowCount(int stuckArrowCount) -
getStingerCount
public final int getStingerCount() -
setStingerCount
public final void setStingerCount(int stingerCount) -
getHandSwingDuration
private int getHandSwingDuration() -
swingHand
-
swingHand
-
handleStatus
@Environment(CLIENT) public void handleStatus(byte status)- Overrides:
handleStatus
in classEntity
-
method_30127
@Environment(CLIENT) private void method_30127() -
destroy
protected void destroy() -
tickHandSwing
protected void tickHandSwing() -
getAttributeInstance
-
getAttributeValue
-
getAttributeBaseValue
-
getAttributes
-
getGroup
-
getMainHandStack
-
getOffHandStack
-
isHolding
Checks if this entity is holding a certain item.This checks both the entity's main and off hand.
-
isHolding
Checks if this entity is holding a certain item.This checks both the entity's main and off hand.
-
getStackInHand
-
setStackInHand
-
hasStackEquipped
-
getArmorItems
- Overrides:
getArmorItems
in classEntity
-
getEquippedStack
-
equipStack
- Overrides:
equipStack
in classEntity
-
getArmorVisibility
public float getArmorVisibility() -
setSprinting
public void setSprinting(boolean sprinting)- Overrides:
setSprinting
in classEntity
-
getSoundVolume
protected float getSoundVolume() -
getSoundPitch
protected float getSoundPitch() -
isImmobile
protected boolean isImmobile() -
pushAwayFrom
- Overrides:
pushAwayFrom
in classEntity
-
onDismounted
-
shouldRenderName
@Environment(CLIENT) public boolean shouldRenderName()- Overrides:
shouldRenderName
in classEntity
-
getJumpVelocity
protected float getJumpVelocity() -
jump
protected void jump() -
knockDownwards
@Environment(CLIENT) protected void knockDownwards() -
swimUpward
-
getBaseMovementSpeedMultiplier
protected float getBaseMovementSpeedMultiplier() -
canWalkOnFluid
-
travel
-
method_29242
-
method_26318
-
method_26317
-
applyClimbingSpeed
-
getMovementSpeed
private float getMovementSpeed(float slipperiness) -
getMovementSpeed
public float getMovementSpeed() -
setMovementSpeed
public void setMovementSpeed(float movementSpeed) -
tryAttack
-
tick
public void tick() -
method_30128
private void method_30128() -
method_30129
-
method_30121
-
method_30123
-
method_30125
-
method_30122
-
method_30126
-
method_30124
-
turnHead
protected float turnHead(float bodyRotation, float headRotation) -
tickMovement
public void tickMovement() -
hurtByWater
public boolean hurtByWater() -
initAi
private void initAi() -
tickNewAi
protected void tickNewAi() -
tickCramming
protected void tickCramming() -
tickRiptide
-
pushAway
-
attackLivingEntity
-
setRiptideTicks
public void setRiptideTicks(int int2) -
isUsingRiptide
public boolean isUsingRiptide() -
stopRiding
public void stopRiding()- Overrides:
stopRiding
in classEntity
-
tickRiding
public void tickRiding()- Overrides:
tickRiding
in classEntity
-
updateTrackedPositionAndAngles
@Environment(CLIENT) public void updateTrackedPositionAndAngles(double x, double y, double z, float yaw, float pitch, int interpolationSteps, boolean interpolate)- Overrides:
updateTrackedPositionAndAngles
in classEntity
-
updateTrackedHeadRotation
@Environment(CLIENT) public void updateTrackedHeadRotation(float yaw, int interpolationSteps)- Overrides:
updateTrackedHeadRotation
in classEntity
-
setJumping
public void setJumping(boolean jumping) -
method_29499
-
sendPickup
-
canSee
-
getYaw
public float getYaw(float tickDelta) -
getHandSwingProgress
@Environment(CLIENT) public float getHandSwingProgress(float tickDelta) -
canMoveVoluntarily
public boolean canMoveVoluntarily() -
collides
public boolean collides() -
isPushable
public boolean isPushable()- Overrides:
isPushable
in classEntity
-
scheduleVelocityUpdate
protected void scheduleVelocityUpdate()- Overrides:
scheduleVelocityUpdate
in classEntity
-
getHeadYaw
public float getHeadYaw()- Overrides:
getHeadYaw
in classEntity
-
setHeadYaw
public void setHeadYaw(float headYaw)- Overrides:
setHeadYaw
in classEntity
-
setYaw
public void setYaw(float yaw) -
method_30633
- Overrides:
method_30633
in classEntity
-
method_31079
-
getAbsorptionAmount
public float getAbsorptionAmount() -
setAbsorptionAmount
public void setAbsorptionAmount(float amount) -
enterCombat
public void enterCombat() -
endCombat
public void endCombat() -
markEffectsDirty
protected void markEffectsDirty() -
getMainArm
-
isUsingItem
public boolean isUsingItem() -
getActiveHand
-
tickActiveItemStack
private void tickActiveItemStack() -
shouldSpawnConsumptionEffects
private boolean shouldSpawnConsumptionEffects() -
updateLeaningPitch
private void updateLeaningPitch() -
setLivingFlag
protected void setLivingFlag(int mask, boolean value) -
setCurrentHand
-
onTrackedDataSet
- Overrides:
onTrackedDataSet
in classEntity
-
lookAt
-
spawnConsumptionEffects
-
spawnItemParticles
-
consumeItem
protected void consumeItem() -
getActiveItem
-
getItemUseTimeLeft
public int getItemUseTimeLeft() -
getItemUseTime
public int getItemUseTime() -
stopUsingItem
public void stopUsingItem() -
clearActiveItem
public void clearActiveItem() -
isBlocking
public boolean isBlocking() -
isHoldingOntoLadder
public boolean isHoldingOntoLadder()- Returns:
true
if this entity should not lose height while in a climbing state- See Also:
LivingEntity
-
isFallFlying
public boolean isFallFlying() -
isInSwimmingPose
public boolean isInSwimmingPose()- Overrides:
isInSwimmingPose
in classEntity
-
getRoll
@Environment(CLIENT) public int getRoll() -
teleport
public boolean teleport(double x, double y, double z, boolean particleEffects) -
isAffectedBySplashPotions
public boolean isAffectedBySplashPotions() -
isMobOrPlayer
public boolean isMobOrPlayer() -
setNearbySongPlaying
-
canEquip
-
createSpawnPacket
- Specified by:
createSpawnPacket
in classEntity
-
getDimensions
- Overrides:
getDimensions
in classEntity
-
getPoses
-
getBoundingBox
-
getSleepingPosition
-
setSleepingPosition
-
clearSleepingPosition
public void clearSleepingPosition() -
isSleeping
public boolean isSleeping() -
sleep
-
setPositionInBed
-
isSleepingInBed
private boolean isSleepingInBed() -
wakeUp
public void wakeUp() -
getSleepingDirection
-
isInsideWall
public boolean isInsideWall()- Overrides:
isInsideWall
in classEntity
-
getEyeHeight
- Overrides:
getEyeHeight
in classEntity
-
getActiveEyeHeight
-
getArrowType
-
eatFood
-
applyFoodEffects
-
getEquipmentBreakStatus
-
sendEquipmentBreakStatus
-
sendToolBreakStatus
-
getVisibilityBoundingBox
- Overrides:
getVisibilityBoundingBox
in classEntity
-