Interface LivingEntity
- All Superinterfaces:
- Attributable,- CommandSender,- Damageable,- Entity,- Metadatable,- Nameable,- Permissible,- PersistentDataHolder,- ProjectileSource,- ServerOperator
- All Known Subinterfaces:
- AbstractHorse,- AbstractSkeleton,- AbstractVillager,- Ageable,- Allay,- Ambient,- Animals,- ArmorStand,- Axolotl,- Bat,- Bee,- Blaze,- Breedable,- Camel,- Cat,- CaveSpider,- ChestedHorse,- Chicken,- Cod,- ComplexLivingEntity,- Cow,- Creature,- Creeper,- Dolphin,- Donkey,- Drowned,- ElderGuardian,- EnderDragon,- Enderman,- Endermite,- Enemy,- Evoker,- Fish,- Flying,- Fox,- Frog,- Ghast,- Giant,- GlowSquid,- Goat,- Golem,- Guardian,- Hoglin,- Horse,- HumanEntity,- Husk,- Illager,- Illusioner,- IronGolem,- Llama,- MagmaCube,- Mob,- Monster,- Mule,- MushroomCow,- NPC,- Ocelot,- Panda,- Parrot,- Phantom,- Pig,- Piglin,- PiglinAbstract,- PiglinBrute,- PigZombie,- Pillager,- Player,- PolarBear,- PufferFish,- Rabbit,- Raider,- Ravager,- Salmon,- Sheep,- Shulker,- Silverfish,- Skeleton,- SkeletonHorse,- Slime,- Snowman,- Spellcaster,- Spider,- Squid,- Steerable,- Stray,- Strider,- Tadpole,- Tameable,- TraderLlama,- TropicalFish,- Turtle,- Vex,- Villager,- Vindicator,- WanderingTrader,- Warden,- WaterMob,- Witch,- Wither,- WitherSkeleton,- Wolf,- Zoglin,- Zombie,- ZombieHorse,- ZombieVillager
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.bukkit.entity.EntityEntity.Spigot
- 
Method SummaryModifier and TypeMethodDescriptionbooleanaddPotionEffect(PotionEffect effect) Adds the givenPotionEffectto the living entity.booleanaddPotionEffect(PotionEffect effect, boolean force) Deprecated.no need to force since multiple effects of the same type are now supported.booleanaddPotionEffects(Collection<PotionEffect> effects) Attempts to add all of the givenPotionEffectto the living entity.voidMakes this entity attack the given entity with a melee attack.booleanReturns true if this entity can breathe underwater and will not take suffocation damage when its air supply reaches zero.Returns all currently activePotionEffects on the living entity.intGets the time in ticks until the next arrow leaves the entity's body.intGets the amount of arrows in an entity's body.booleanGets if the living entity can pick up items.Get the category to which this entity belongs.Gets a mutable set of UUIDs of the entities which are exempt from the entity's collidable rule and which's collision with this entity will behave the opposite of it.Get theSoundthis entity will make on death.getDrinkingSound(ItemStack itemStack) getEatingSound(ItemStack itemStack) Gets the inventory with the equipment worn by the living entity.doubleGets the height of the living entity's eyes above its Location.doublegetEyeHeight(boolean ignorePose) Gets the height of the living entity's eyes above its Location.Get a Location detailing the current eye position of the living entity.getFallDamageSound(int fallHeight) Get theSoundthis entity will make when falling from the given height (in blocks).Get theSoundthis entity will make when falling from a large height.Get theSoundthis entity will make when falling from a small height.Get theSoundthis entity will make when damaged.Gets the player identified as the killer of the living entity.doubleReturns the living entity's last damage taken in the current no damage ticks time.getLastTwoTargetBlocks(Set<Material> transparent, int maxDistance) Gets the last two blocks along the living entity's line of sight.Gets the entity that is currently leading this entity.getLineOfSight(Set<Material> transparent, int maxDistance) Gets all blocks along the living entity's line of sight.intReturns the maximum amount of air the living entity can have, in ticks.intReturns the living entity's current maximum no damage ticks.<T> TReturns the value of the memory specified.intReturns the living entity's current no damage ticks.Returns the activePotionEffectof the specified type.intReturns the amount of air that the living entity has remaining, in ticks.booleanReturns if the living entity despawns when away from players or not.getTargetBlock(Set<Material> transparent, int maxDistance) Gets the block that the living entity has targeted.getTargetBlockExact(int maxDistance) Gets the block that the living entity has targeted.getTargetBlockExact(int maxDistance, FluidCollisionMode fluidCollisionMode) Gets the block that the living entity has targeted.booleanhasAI()Checks whether an entity has AI.booleanhasLineOfSight(Entity other) Checks whether the living entity has block line of sight to another.booleanReturns whether the living entity already has an existing effect of the givenPotionEffectTypeapplied to it.booleanGets if the entity is climbing.booleanGets if this entity is subject to collisions with other entities.booleanChecks to see if an entity is gliding, such as using an Elytra.booleanGets whether the entity is invisible or not.booleanReturns whether the entity is currently leashed.booleanChecks to see if an entity is currently using the Riptide enchantment.booleanReturns whether this entity is slumbering.booleanChecks to see if an entity is swimming.rayTraceBlocks(double maxDistance) Performs a ray trace that provides information on the targeted block.rayTraceBlocks(double maxDistance, FluidCollisionMode fluidCollisionMode) Performs a ray trace that provides information on the targeted block.voidRemoves any effects present of the givenPotionEffectType.voidsetAI(boolean ai) Sets whether an entity will have AI.voidsetArrowCooldown(int ticks) Sets the time in ticks until the next arrow leaves the entity's body.voidsetArrowsInBody(int count) Set the amount of arrows in the entity's body.voidsetCanPickupItems(boolean pickup) Sets whether or not the living entity can pick up items.voidsetCollidable(boolean collidable) Set if this entity will be subject to collisions with other entities.voidsetGliding(boolean gliding) Makes entity start or stop gliding.voidsetInvisible(boolean invisible) Sets whether the entity is invisible or not.voidsetLastDamage(double damage) Sets the damage dealt within the current no damage ticks time period.booleansetLeashHolder(Entity holder) Sets the leash on this entity to be held by the supplied entity.voidsetMaximumAir(int ticks) Sets the maximum amount of air the living entity can have, in ticks.voidsetMaximumNoDamageTicks(int ticks) Sets the living entity's current maximum no damage ticks.<T> voidSets the value of the memory specified.voidsetNoDamageTicks(int ticks) Sets the living entity's current no damage ticks.voidsetRemainingAir(int ticks) Sets the amount of air that the living entity has remaining, in ticks.voidsetRemoveWhenFarAway(boolean remove) Sets whether or not the living entity despawns when away from players or not.voidsetSwimming(boolean swimming) Makes entity start or stop swimming.voidMakes this entity swing their main hand.voidMakes this entity swing their off hand.Methods inherited from interface org.bukkit.attribute.AttributablegetAttributeMethods inherited from interface org.bukkit.command.CommandSendergetName, sendMessage, sendMessage, sendMessage, sendMessageMethods inherited from interface org.bukkit.entity.Damageabledamage, damage, getAbsorptionAmount, getHealth, getMaxHealth, resetMaxHealth, setAbsorptionAmount, setHealth, setMaxHealthMethods inherited from interface org.bukkit.entity.EntityaddPassenger, addScoreboardTag, eject, getBoundingBox, getEntityId, getFacing, getFallDistance, getFireTicks, getFreezeTicks, getHeight, getLastDamageCause, getLocation, getLocation, getMaxFireTicks, getMaxFreezeTicks, getNearbyEntities, getPassenger, getPassengers, getPistonMoveReaction, getPortalCooldown, getPose, getScoreboardTags, getServer, getSpawnCategory, getSwimHighSpeedSplashSound, getSwimSound, getSwimSplashSound, getTicksLived, getType, getUniqueId, getVehicle, getVelocity, getWidth, getWorld, hasGravity, isCustomNameVisible, isDead, isEmpty, isFrozen, isGlowing, isInsideVehicle, isInvulnerable, isInWater, isOnGround, isPersistent, isSilent, isValid, isVisibleByDefault, isVisualFire, leaveVehicle, playEffect, remove, removePassenger, removeScoreboardTag, setCustomNameVisible, setFallDistance, setFireTicks, setFreezeTicks, setGlowing, setGravity, setInvulnerable, setLastDamageCause, setPassenger, setPersistent, setPortalCooldown, setRotation, setSilent, setTicksLived, setVelocity, setVisibleByDefault, setVisualFire, spigot, teleport, teleport, teleport, teleportMethods inherited from interface org.bukkit.metadata.MetadatablegetMetadata, hasMetadata, removeMetadata, setMetadataMethods inherited from interface org.bukkit.NameablegetCustomName, setCustomNameMethods inherited from interface org.bukkit.permissions.PermissibleaddAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, recalculatePermissions, removeAttachmentMethods inherited from interface org.bukkit.persistence.PersistentDataHoldergetPersistentDataContainerMethods inherited from interface org.bukkit.projectiles.ProjectileSourcelaunchProjectile, launchProjectileMethods inherited from interface org.bukkit.permissions.ServerOperatorisOp, setOp
- 
Method Details- 
getEyeHeightdouble getEyeHeight()Gets the height of the living entity's eyes above its Location.- Returns:
- height of the living entity's eyes above its location
 
- 
getEyeHeightdouble getEyeHeight(boolean ignorePose) Gets the height of the living entity's eyes above its Location.- Parameters:
- ignorePose- if set to true, the effects of pose changes, eg sneaking and gliding will be ignored
- Returns:
- height of the living entity's eyes above its location
 
- 
getEyeLocationGet a Location detailing the current eye position of the living entity.- Returns:
- a location at the eyes of the living entity
 
- 
getLineOfSightGets all blocks along the living entity's line of sight.This list contains all blocks from the living entity's eye position to target inclusive. This method considers all blocks as 1x1x1 in size. - Parameters:
- transparent- Set containing all transparent block Materials (set to null for only air)
- maxDistance- this is the maximum distance to scan (may be limited by server by at least 100 blocks, no less)
- Returns:
- list containing all blocks along the living entity's line of sight
 
- 
getTargetBlockGets the block that the living entity has targeted.This method considers all blocks as 1x1x1 in size. To take exact block collision shapes into account, see getTargetBlockExact(int, FluidCollisionMode).- Parameters:
- transparent- Set containing all transparent block Materials (set to null for only air)
- maxDistance- this is the maximum distance to scan (may be limited by server by at least 100 blocks, no less)
- Returns:
- block that the living entity has targeted
 
- 
getLastTwoTargetBlocksGets the last two blocks along the living entity's line of sight.The target block will be the last block in the list. This method considers all blocks as 1x1x1 in size. - Parameters:
- transparent- Set containing all transparent block Materials (set to null for only air)
- maxDistance- this is the maximum distance to scan. This may be further limited by the server, but never to less than 100 blocks
- Returns:
- list containing the last 2 blocks along the living entity's line of sight
 
- 
getTargetBlockExactGets the block that the living entity has targeted.This takes the blocks' precise collision shapes into account. Fluids are ignored. This may cause loading of chunks! Some implementations may impose artificial restrictions on the maximum distance. - Parameters:
- maxDistance- the maximum distance to scan
- Returns:
- block that the living entity has targeted
- See Also:
 
- 
getTargetBlockExact@Nullable Block getTargetBlockExact(int maxDistance, @NotNull FluidCollisionMode fluidCollisionMode) Gets the block that the living entity has targeted.This takes the blocks' precise collision shapes into account. This may cause loading of chunks! Some implementations may impose artificial restrictions on the maximum distance. - Parameters:
- maxDistance- the maximum distance to scan
- fluidCollisionMode- the fluid collision mode
- Returns:
- block that the living entity has targeted
- See Also:
 
- 
rayTraceBlocksPerforms a ray trace that provides information on the targeted block.This takes the blocks' precise collision shapes into account. Fluids are ignored. This may cause loading of chunks! Some implementations may impose artificial restrictions on the maximum distance. - Parameters:
- maxDistance- the maximum distance to scan
- Returns:
- information on the targeted block, or nullif there is no targeted block in range
- See Also:
 
- 
rayTraceBlocks@Nullable RayTraceResult rayTraceBlocks(double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode) Performs a ray trace that provides information on the targeted block.This takes the blocks' precise collision shapes into account. This may cause loading of chunks! Some implementations may impose artificial restrictions on the maximum distance. - Parameters:
- maxDistance- the maximum distance to scan
- fluidCollisionMode- the fluid collision mode
- Returns:
- information on the targeted block, or nullif there is no targeted block in range
- See Also:
 
- 
getRemainingAirint getRemainingAir()Returns the amount of air that the living entity has remaining, in ticks.- Returns:
- amount of air remaining
 
- 
setRemainingAirvoid setRemainingAir(int ticks) Sets the amount of air that the living entity has remaining, in ticks.- Parameters:
- ticks- amount of air remaining
 
- 
getMaximumAirint getMaximumAir()Returns the maximum amount of air the living entity can have, in ticks.- Returns:
- maximum amount of air
 
- 
setMaximumAirvoid setMaximumAir(int ticks) Sets the maximum amount of air the living entity can have, in ticks.- Parameters:
- ticks- maximum amount of air
 
- 
getArrowCooldownint getArrowCooldown()Gets the time in ticks until the next arrow leaves the entity's body.- Returns:
- ticks until arrow leaves
 
- 
setArrowCooldownvoid setArrowCooldown(int ticks) Sets the time in ticks until the next arrow leaves the entity's body.- Parameters:
- ticks- time until arrow leaves
 
- 
getArrowsInBodyint getArrowsInBody()Gets the amount of arrows in an entity's body.- Returns:
- amount of arrows in body
 
- 
setArrowsInBodyvoid setArrowsInBody(int count) Set the amount of arrows in the entity's body.- Parameters:
- count- amount of arrows in entity's body
 
- 
getMaximumNoDamageTicksint getMaximumNoDamageTicks()Returns the living entity's current maximum no damage ticks.This is the maximum duration in which the living entity will not take damage. - Returns:
- maximum no damage ticks
 
- 
setMaximumNoDamageTicksvoid setMaximumNoDamageTicks(int ticks) Sets the living entity's current maximum no damage ticks.- Parameters:
- ticks- maximum amount of no damage ticks
 
- 
getLastDamagedouble getLastDamage()Returns the living entity's last damage taken in the current no damage ticks time.Only damage higher than this amount will further damage the living entity. - Returns:
- damage taken since the last no damage ticks time period
 
- 
setLastDamagevoid setLastDamage(double damage) Sets the damage dealt within the current no damage ticks time period.- Parameters:
- damage- amount of damage
 
- 
getNoDamageTicksint getNoDamageTicks()Returns the living entity's current no damage ticks.- Returns:
- amount of no damage ticks
 
- 
setNoDamageTicksvoid setNoDamageTicks(int ticks) Sets the living entity's current no damage ticks.- Parameters:
- ticks- amount of no damage ticks
 
- 
getKillerGets the player identified as the killer of the living entity.May be null. - Returns:
- killer player, or null if none found
 
- 
addPotionEffectAdds the givenPotionEffectto the living entity.- Parameters:
- effect- PotionEffect to be added
- Returns:
- whether the effect could be added
 
- 
addPotionEffectDeprecated.no need to force since multiple effects of the same type are now supported.Adds the givenPotionEffectto the living entity.Only one potion effect can be present for a given PotionEffectType.- Parameters:
- effect- PotionEffect to be added
- force- whether conflicting effects should be removed
- Returns:
- whether the effect could be added
 
- 
addPotionEffectsAttempts to add all of the givenPotionEffectto the living entity.- Parameters:
- effects- the effects to add
- Returns:
- whether all of the effects could be added
 
- 
hasPotionEffectReturns whether the living entity already has an existing effect of the givenPotionEffectTypeapplied to it.- Parameters:
- type- the potion type to check
- Returns:
- whether the living entity has this potion effect active on them
 
- 
getPotionEffectReturns the activePotionEffectof the specified type.If the effect is not present on the entity then null will be returned. - Parameters:
- type- the potion type to check
- Returns:
- the effect active on this entity, or null if not active.
 
- 
removePotionEffectRemoves any effects present of the givenPotionEffectType.- Parameters:
- type- the potion type to remove
 
- 
getActivePotionEffectsReturns all currently activePotionEffects on the living entity.- Returns:
- a collection of PotionEffects
 
- 
hasLineOfSightChecks whether the living entity has block line of sight to another.This uses the same algorithm that hostile mobs use to find the closest player. - Parameters:
- other- the entity to determine line of sight to
- Returns:
- true if there is a line of sight, false if not
 
- 
getRemoveWhenFarAwayboolean getRemoveWhenFarAway()Returns if the living entity despawns when away from players or not.By default, animals are not removed while other mobs are. - Returns:
- true if the living entity is removed when away from players
 
- 
setRemoveWhenFarAwayvoid setRemoveWhenFarAway(boolean remove) Sets whether or not the living entity despawns when away from players or not.- Parameters:
- remove- the removal status
 
- 
getEquipmentGets the inventory with the equipment worn by the living entity.- Returns:
- the living entity's inventory
 
- 
setCanPickupItemsvoid setCanPickupItems(boolean pickup) Sets whether or not the living entity can pick up items.- Parameters:
- pickup- whether or not the living entity can pick up items
 
- 
getCanPickupItemsboolean getCanPickupItems()Gets if the living entity can pick up items.- Returns:
- whether or not the living entity can pick up items
 
- 
isLeashedboolean isLeashed()Returns whether the entity is currently leashed.- Returns:
- whether the entity is leashed
 
- 
getLeashHolderGets the entity that is currently leading this entity.- Returns:
- the entity holding the leash
- Throws:
- IllegalStateException- if not currently leashed
 
- 
setLeashHolderSets the leash on this entity to be held by the supplied entity.This method has no effect on EnderDragons, Withers, Players, or Bats. Non-living entities excluding leashes will not persist as leash holders. - Parameters:
- holder- the entity to leash this entity to, or null to unleash
- Returns:
- whether the operation was successful
 
- 
isGlidingboolean isGliding()Checks to see if an entity is gliding, such as using an Elytra.- Returns:
- True if this entity is gliding.
 
- 
setGlidingvoid setGliding(boolean gliding) Makes entity start or stop gliding. This will work even if an Elytra is not equipped, but will be reverted by the server immediately after unless an event-cancelling mechanism is put in place.- Parameters:
- gliding- True if the entity is gliding.
 
- 
isSwimmingboolean isSwimming()Checks to see if an entity is swimming.- Returns:
- True if this entity is swimming.
 
- 
setSwimmingvoid setSwimming(boolean swimming) Makes entity start or stop swimming. This may have unexpected results if the entity is not in water.- Parameters:
- swimming- True if the entity is swimming.
 
- 
isRiptidingboolean isRiptiding()Checks to see if an entity is currently using the Riptide enchantment.- Returns:
- True if this entity is currently riptiding.
 
- 
isSleepingboolean isSleeping()Returns whether this entity is slumbering.- Returns:
- slumber state
 
- 
isClimbingboolean isClimbing()Gets if the entity is climbing.- Returns:
- if the entity is climbing
 
- 
setAIvoid setAI(boolean ai) Sets whether an entity will have AI. The entity will be completely unable to move if it has no AI.- Parameters:
- ai- whether the mob will have AI or not.
 
- 
hasAIboolean hasAI()Checks whether an entity has AI. The entity will be completely unable to move if it has no AI.- Returns:
- true if the entity has AI, otherwise false.
 
- 
attackMakes this entity attack the given entity with a melee attack. Attack damage is calculated by the server from the attributes and equipment of this mob, and knockback is applied totargetas appropriate.- Parameters:
- target- entity to attack.
 
- 
swingMainHandvoid swingMainHand()Makes this entity swing their main hand. This method does nothing if this entity does not have an animation for swinging their main hand.
- 
swingOffHandvoid swingOffHand()Makes this entity swing their off hand. This method does nothing if this entity does not have an animation for swinging their off hand.
- 
setCollidablevoid setCollidable(boolean collidable) Set if this entity will be subject to collisions with other entities.Exemptions to this rule can be managed with getCollidableExemptions()- Parameters:
- collidable- collision status
 
- 
isCollidableboolean isCollidable()Gets if this entity is subject to collisions with other entities.Some entities might be exempted from the collidable rule of this entity. Use getCollidableExemptions()to get these.Please note that this method returns only the custom collidable state, not whether the entity is non-collidable for other reasons such as being dead. - Returns:
- collision status
 
- 
getCollidableExemptionsGets a mutable set of UUIDs of the entities which are exempt from the entity's collidable rule and which's collision with this entity will behave the opposite of it.This set can be modified to add or remove exemptions. For example if collidable is true and an entity is in the exemptions set then it will not collide with it. Similarly if collidable is false and an entity is in this set then it will still collide with it. Note these exemptions are not (currently) persistent. - Returns:
- the collidable exemption set
 
- 
getMemoryReturns the value of the memory specified.Note that the value is null when the specific entity does not have that value by default. - Type Parameters:
- T- the type of the return value
- Parameters:
- memoryKey- memory to access
- Returns:
- a instance of the memory section value or null if not present
 
- 
setMemorySets the value of the memory specified.Note that the value will not be persisted when the specific entity does not have that value by default. - Type Parameters:
- T- the type of the passed value
- Parameters:
- memoryKey- the memory to access
- memoryValue- a typed memory value
 
- 
getHurtSoundGet theSoundthis entity will make when damaged.- Returns:
- the hurt sound, or null if the entity does not make any sound
 
- 
getDeathSoundGet theSoundthis entity will make on death.- Returns:
- the death sound, or null if the entity does not make any sound
 
- 
getFallDamageSoundGet theSoundthis entity will make when falling from the given height (in blocks). The sound will often differ between either a small or a big fall damage sound if the height exceeds 4 blocks.- Parameters:
- fallHeight- the fall height in blocks
- Returns:
- the fall damage sound
- See Also:
 
- 
getFallDamageSoundSmallGet theSoundthis entity will make when falling from a small height.- Returns:
- the fall damage sound
 
- 
getFallDamageSoundBigGet theSoundthis entity will make when falling from a large height.- Returns:
- the fall damage sound
 
- 
getDrinkingSound- Parameters:
- itemStack- the item stack being drank
- Returns:
- the drinking sound
 
- 
getEatingSound- Parameters:
- itemStack- the item stack being eaten
- Returns:
- the eating sound
 
- 
canBreatheUnderwaterboolean canBreatheUnderwater()Returns true if this entity can breathe underwater and will not take suffocation damage when its air supply reaches zero.- Returns:
- trueif the entity can breathe underwater
 
- 
getCategoryGet the category to which this entity belongs. Categories may subject this entity to additional effects, benefits or debuffs.- Returns:
- the entity category
 
- 
setInvisiblevoid setInvisible(boolean invisible) Sets whether the entity is invisible or not.- Parameters:
- invisible- If the entity is invisible
 
- 
isInvisibleboolean isInvisible()Gets whether the entity is invisible or not.- Returns:
- Whether the entity is invisible
 
 
-