Interface LivingEntity
-
- All Superinterfaces:
Attributable
,CommandSender
,Damageable
,Entity
,Metadatable
,Nameable
,Permissible
,PersistentDataHolder
,ProjectileSource
,ServerOperator
- All Known Subinterfaces:
AbstractHorse
,AbstractVillager
,Ageable
,Ambient
,Animals
,ArmorStand
,Bat
,Blaze
,Cat
,CaveSpider
,ChestedHorse
,Chicken
,Cod
,ComplexLivingEntity
,Cow
,Creature
,Creeper
,Dolphin
,Donkey
,Drowned
,ElderGuardian
,EnderDragon
,Enderman
,Endermite
,Evoker
,Fish
,Flying
,Fox
,Ghast
,Giant
,Golem
,Guardian
,Horse
,HumanEntity
,Husk
,Illager
,Illusioner
,IronGolem
,Llama
,MagmaCube
,Mob
,Monster
,Mule
,MushroomCow
,NPC
,Ocelot
,Panda
,Parrot
,Phantom
,Pig
,PigZombie
,Pillager
,Player
,PolarBear
,PufferFish
,Rabbit
,Raider
,Ravager
,Salmon
,Sheep
,Shulker
,Silverfish
,Skeleton
,SkeletonHorse
,Slime
,Snowman
,Spellcaster
,Spider
,Squid
,Stray
,TraderLlama
,TropicalFish
,Turtle
,Vex
,Villager
,Vindicator
,WanderingTrader
,WaterMob
,Witch
,Wither
,WitherSkeleton
,Wolf
,Zombie
,ZombieHorse
,ZombieVillager
public interface LivingEntity extends Attributable, Damageable, ProjectileSource
Represents a living entity, such as a monster or player
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.bukkit.entity.Entity
Entity.Spigot
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
addPotionEffect(PotionEffect effect)
Adds the givenPotionEffect
to the living entity.boolean
addPotionEffect(PotionEffect effect, boolean force)
Adds the givenPotionEffect
to the living entity.boolean
addPotionEffects(Collection<PotionEffect> effects)
Attempts to add all of the givenPotionEffect
to the living entity.Collection<PotionEffect>
getActivePotionEffects()
Returns all currently activePotionEffect
s on the living entity.boolean
getCanPickupItems()
Gets if the living entity can pick up items.EntityEquipment
getEquipment()
Gets the inventory with the equipment worn by the living entity.double
getEyeHeight()
Gets the height of the living entity's eyes above its Location.double
getEyeHeight(boolean ignorePose)
Gets the height of the living entity's eyes above its Location.Location
getEyeLocation()
Get a Location detailing the current eye position of the living entity.Player
getKiller()
Gets the player identified as the killer of the living entity.double
getLastDamage()
Returns the living entity's last damage taken in the current no damage ticks time.List<Block>
getLastTwoTargetBlocks(Set<Material> transparent, int maxDistance)
Gets the last two blocks along the living entity's line of sight.Entity
getLeashHolder()
Gets the entity that is currently leading this entity.List<Block>
getLineOfSight(Set<Material> transparent, int maxDistance)
Gets all blocks along the living entity's line of sight.int
getMaximumAir()
Returns the maximum amount of air the living entity can have, in ticks.int
getMaximumNoDamageTicks()
Returns the living entity's current maximum no damage ticks.<T> T
getMemory(MemoryKey<T> memoryKey)
Returns the value of the memory specified.int
getNoDamageTicks()
Returns the living entity's current no damage ticks.PotionEffect
getPotionEffect(PotionEffectType type)
Returns the activePotionEffect
of the specified type.int
getRemainingAir()
Returns the amount of air that the living entity has remaining, in ticks.boolean
getRemoveWhenFarAway()
Returns if the living entity despawns when away from players or not.Block
getTargetBlock(Set<Material> transparent, int maxDistance)
Gets the block that the living entity has targeted.Block
getTargetBlockExact(int maxDistance)
Gets the block that the living entity has targeted.Block
getTargetBlockExact(int maxDistance, FluidCollisionMode fluidCollisionMode)
Gets the block that the living entity has targeted.boolean
hasAI()
Checks whether an entity has AI.boolean
hasLineOfSight(Entity other)
Checks whether the living entity has block line of sight to another.boolean
hasPotionEffect(PotionEffectType type)
Returns whether the living entity already has an existing effect of the givenPotionEffectType
applied to it.boolean
isCollidable()
Gets if this entity is subject to collisions with other entities.boolean
isGliding()
Checks to see if an entity is gliding, such as using an Elytra.boolean
isLeashed()
Returns whether the entity is currently leashed.boolean
isRiptiding()
Checks to see if an entity is currently using the Riptide enchantment.boolean
isSleeping()
Returns whether this entity is slumbering.boolean
isSwimming()
Checks to see if an entity is swimming.RayTraceResult
rayTraceBlocks(double maxDistance)
Performs a ray trace that provides information on the targeted block.RayTraceResult
rayTraceBlocks(double maxDistance, FluidCollisionMode fluidCollisionMode)
Performs a ray trace that provides information on the targeted block.void
removePotionEffect(PotionEffectType type)
Removes any effects present of the givenPotionEffectType
.void
setAI(boolean ai)
Sets whether an entity will have AI.void
setCanPickupItems(boolean pickup)
Sets whether or not the living entity can pick up items.void
setCollidable(boolean collidable)
Set if this entity will be subject to collisions other entities.void
setGliding(boolean gliding)
Makes entity start or stop gliding.void
setLastDamage(double damage)
Sets the damage dealt within the current no damage ticks time period.boolean
setLeashHolder(Entity holder)
Sets the leash on this entity to be held by the supplied entity.void
setMaximumAir(int ticks)
Sets the maximum amount of air the living entity can have, in ticks.void
setMaximumNoDamageTicks(int ticks)
Sets the living entity's current maximum no damage ticks.<T> void
setMemory(MemoryKey<T> memoryKey, T memoryValue)
Sets the value of the memory specified.void
setNoDamageTicks(int ticks)
Sets the living entity's current no damage ticks.void
setRemainingAir(int ticks)
Sets the amount of air that the living entity has remaining, in ticks.void
setRemoveWhenFarAway(boolean remove)
Sets whether or not the living entity despawns when away from players or not.void
setSwimming(boolean swimming)
Makes entity start or stop swimming.-
Methods inherited from interface org.bukkit.attribute.Attributable
getAttribute
-
Methods inherited from interface org.bukkit.command.CommandSender
getName, sendMessage, sendMessage
-
Methods inherited from interface org.bukkit.entity.Damageable
damage, damage, getAbsorptionAmount, getHealth, getMaxHealth, resetMaxHealth, setAbsorptionAmount, setHealth, setMaxHealth
-
Methods inherited from interface org.bukkit.entity.Entity
addPassenger, addScoreboardTag, eject, getBoundingBox, getEntityId, getFacing, getFallDistance, getFireTicks, getHeight, getLastDamageCause, getLocation, getLocation, getMaxFireTicks, getNearbyEntities, getPassenger, getPassengers, getPistonMoveReaction, getPortalCooldown, getPose, getScoreboardTags, getServer, getTicksLived, getType, getUniqueId, getVehicle, getVelocity, getWidth, getWorld, hasGravity, isCustomNameVisible, isDead, isEmpty, isGlowing, isInsideVehicle, isInvulnerable, isOnGround, isPersistent, isSilent, isValid, leaveVehicle, playEffect, remove, removePassenger, removeScoreboardTag, setCustomNameVisible, setFallDistance, setFireTicks, setGlowing, setGravity, setInvulnerable, setLastDamageCause, setPassenger, setPersistent, setPortalCooldown, setRotation, setSilent, setTicksLived, setVelocity, spigot, teleport, teleport, teleport, teleport
-
Methods inherited from interface org.bukkit.metadata.Metadatable
getMetadata, hasMetadata, removeMetadata, setMetadata
-
Methods inherited from interface org.bukkit.Nameable
getCustomName, setCustomName
-
Methods inherited from interface org.bukkit.permissions.Permissible
addAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, recalculatePermissions, removeAttachment
-
Methods inherited from interface org.bukkit.persistence.PersistentDataHolder
getPersistentDataContainer
-
Methods inherited from interface org.bukkit.projectiles.ProjectileSource
launchProjectile, launchProjectile
-
Methods inherited from interface org.bukkit.permissions.ServerOperator
isOp, setOp
-
-
-
-
Method Detail
-
getEyeHeight
double getEyeHeight()
Gets the height of the living entity's eyes above its Location.- Returns:
- height of the living entity's eyes above its location
-
getEyeHeight
double 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
-
getEyeLocation
@NotNull Location getEyeLocation()
Get a Location detailing the current eye position of the living entity.- Returns:
- a location at the eyes of the living entity
-
getLineOfSight
@NotNull List<Block> getLineOfSight(@Nullable Set<Material> transparent, int maxDistance)
Gets 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
- HashSet 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
-
getTargetBlock
@NotNull Block getTargetBlock(@Nullable Set<Material> transparent, int maxDistance)
Gets 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
- HashSet 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
-
getLastTwoTargetBlocks
@NotNull List<Block> getLastTwoTargetBlocks(@Nullable Set<Material> transparent, int maxDistance)
Gets 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
- HashSet 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
-
getTargetBlockExact
@Nullable Block getTargetBlockExact(int maxDistance)
Gets 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(int, org.bukkit.FluidCollisionMode)
-
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 scanfluidCollisionMode
- the fluid collision mode- Returns:
- block that the living entity has targeted
- See Also:
rayTraceBlocks(double, FluidCollisionMode)
-
rayTraceBlocks
@Nullable RayTraceResult rayTraceBlocks(double maxDistance)
Performs 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
null
if there is no targeted block in range - See Also:
rayTraceBlocks(double, FluidCollisionMode)
-
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 scanfluidCollisionMode
- the fluid collision mode- Returns:
- information on the targeted block, or
null
if there is no targeted block in range - See Also:
World.rayTraceBlocks(Location, Vector, double, FluidCollisionMode)
-
getRemainingAir
int getRemainingAir()
Returns the amount of air that the living entity has remaining, in ticks.- Returns:
- amount of air remaining
-
setRemainingAir
void setRemainingAir(int ticks)
Sets the amount of air that the living entity has remaining, in ticks.- Parameters:
ticks
- amount of air remaining
-
getMaximumAir
int getMaximumAir()
Returns the maximum amount of air the living entity can have, in ticks.- Returns:
- maximum amount of air
-
setMaximumAir
void setMaximumAir(int ticks)
Sets the maximum amount of air the living entity can have, in ticks.- Parameters:
ticks
- maximum amount of air
-
getMaximumNoDamageTicks
int 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
-
setMaximumNoDamageTicks
void setMaximumNoDamageTicks(int ticks)
Sets the living entity's current maximum no damage ticks.- Parameters:
ticks
- maximum amount of no damage ticks
-
getLastDamage
double 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
-
setLastDamage
void setLastDamage(double damage)
Sets the damage dealt within the current no damage ticks time period.- Parameters:
damage
- amount of damage
-
getNoDamageTicks
int getNoDamageTicks()
Returns the living entity's current no damage ticks.- Returns:
- amount of no damage ticks
-
setNoDamageTicks
void setNoDamageTicks(int ticks)
Sets the living entity's current no damage ticks.- Parameters:
ticks
- amount of no damage ticks
-
getKiller
@Nullable Player getKiller()
Gets the player identified as the killer of the living entity.May be null.
- Returns:
- killer player, or null if none found
-
addPotionEffect
boolean addPotionEffect(@NotNull PotionEffect effect)
Adds the givenPotionEffect
to the living entity.Only one potion effect can be present for a given
PotionEffectType
.- Parameters:
effect
- PotionEffect to be added- Returns:
- whether the effect could be added
-
addPotionEffect
boolean addPotionEffect(@NotNull PotionEffect effect, boolean force)
Adds the givenPotionEffect
to the living entity.Only one potion effect can be present for a given
PotionEffectType
.- Parameters:
effect
- PotionEffect to be addedforce
- whether conflicting effects should be removed- Returns:
- whether the effect could be added
-
addPotionEffects
boolean addPotionEffects(@NotNull Collection<PotionEffect> effects)
Attempts to add all of the givenPotionEffect
to the living entity.- Parameters:
effects
- the effects to add- Returns:
- whether all of the effects could be added
-
hasPotionEffect
boolean hasPotionEffect(@NotNull PotionEffectType type)
Returns whether the living entity already has an existing effect of the givenPotionEffectType
applied to it.- Parameters:
type
- the potion type to check- Returns:
- whether the living entity has this potion effect active on them
-
getPotionEffect
@Nullable PotionEffect getPotionEffect(@NotNull PotionEffectType type)
Returns the activePotionEffect
of 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.
-
removePotionEffect
void removePotionEffect(@NotNull PotionEffectType type)
Removes any effects present of the givenPotionEffectType
.- Parameters:
type
- the potion type to remove
-
getActivePotionEffects
@NotNull Collection<PotionEffect> getActivePotionEffects()
Returns all currently activePotionEffect
s on the living entity.- Returns:
- a collection of
PotionEffect
s
-
hasLineOfSight
boolean hasLineOfSight(@NotNull Entity other)
Checks 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
-
getRemoveWhenFarAway
boolean 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
-
setRemoveWhenFarAway
void setRemoveWhenFarAway(boolean remove)
Sets whether or not the living entity despawns when away from players or not.- Parameters:
remove
- the removal status
-
getEquipment
@Nullable EntityEquipment getEquipment()
Gets the inventory with the equipment worn by the living entity.- Returns:
- the living entity's inventory
-
setCanPickupItems
void 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
-
getCanPickupItems
boolean getCanPickupItems()
Gets if the living entity can pick up items.- Returns:
- whether or not the living entity can pick up items
-
isLeashed
boolean isLeashed()
Returns whether the entity is currently leashed.- Returns:
- whether the entity is leashed
-
getLeashHolder
@NotNull Entity getLeashHolder() throws IllegalStateException
Gets the entity that is currently leading this entity.- Returns:
- the entity holding the leash
- Throws:
IllegalStateException
- if not currently leashed
-
setLeashHolder
boolean setLeashHolder(@Nullable Entity holder)
Sets 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
-
isGliding
boolean isGliding()
Checks to see if an entity is gliding, such as using an Elytra.- Returns:
- True if this entity is gliding.
-
setGliding
void 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.
-
isSwimming
boolean isSwimming()
Checks to see if an entity is swimming.- Returns:
- True if this entity is swimming.
-
setSwimming
void 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.
-
isRiptiding
boolean isRiptiding()
Checks to see if an entity is currently using the Riptide enchantment.- Returns:
- True if this entity is currently riptiding.
-
isSleeping
boolean isSleeping()
Returns whether this entity is slumbering.- Returns:
- slumber state
-
setAI
void setAI(boolean ai)
Sets whether an entity will have AI.- Parameters:
ai
- whether the mob will have AI or not.
-
hasAI
boolean hasAI()
Checks whether an entity has AI.- Returns:
- true if the entity has AI, otherwise false.
-
setCollidable
void setCollidable(boolean collidable)
Set if this entity will be subject to collisions other entities.Note that collisions are bidirectional, so this method would need to be set to false on both the collidee and the collidant to ensure no collisions take place.
- Parameters:
collidable
- collision status
-
isCollidable
boolean isCollidable()
Gets if this entity is subject to collisions with other entities.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
-
getMemory
@Nullable <T> T getMemory(@NotNull MemoryKey<T> memoryKey)
Returns 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
-
setMemory
<T> void setMemory(@NotNull MemoryKey<T> memoryKey, @Nullable T memoryValue)
Sets 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 accessmemoryValue
- a typed memory value
-
-