Interface LivingEntity
- All Superinterfaces:
CommandSender
,Damageable
,Entity
,Metadatable
,Permissible
,ProjectileSource
,ServerOperator
- All Known Subinterfaces:
Ageable
,Ambient
,Animals
,ArmorStand
,Bat
,Blaze
,CaveSpider
,Chicken
,ComplexLivingEntity
,Cow
,Creature
,Creeper
,EnderDragon
,Enderman
,Endermite
,Flying
,Ghast
,Giant
,Golem
,Guardian
,Horse
,HumanEntity
,IronGolem
,MagmaCube
,Monster
,MushroomCow
,NPC
,Ocelot
,Pig
,PigZombie
,Player
,Rabbit
,Sheep
,Silverfish
,Skeleton
,Slime
,Snowman
,Spider
,Squid
,Villager
,WaterMob
,Witch
,Wither
,Wolf
,Zombie
public interface LivingEntity extends Entity, Damageable, ProjectileSource
-
Nested Class Summary
-
Method Summary
Modifier and Type Method Description int
_INVALID_getLastDamage()
Deprecated.void
_INVALID_setLastDamage(int damage)
Deprecated.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(java.util.Collection<PotionEffect> effects)
Attempts to add all of the givenPotionEffect
to the living entity.java.util.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 ignoreSneaking)
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.java.util.List<Block>
getLastTwoTargetBlocks(java.util.HashSet<java.lang.Byte> transparent, int maxDistance)
Deprecated.Magic valuejava.util.List<Block>
getLastTwoTargetBlocks(java.util.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.java.util.List<Block>
getLineOfSight(java.util.HashSet<java.lang.Byte> transparent, int maxDistance)
Deprecated.Magic valuejava.util.List<Block>
getLineOfSight(java.util.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.int
getNoDamageTicks()
Returns the living entity's current no damage ticks.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(java.util.HashSet<java.lang.Byte> transparent, int maxDistance)
Deprecated.Magic valueBlock
getTargetBlock(java.util.Set<Material> transparent, int maxDistance)
Gets the block that the living entity has targeted.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
isLeashed()
Returns whether the entity is currently leashed.void
removePotionEffect(PotionEffectType type)
Removes any effects present of the givenPotionEffectType
.void
setCanPickupItems(boolean pickup)
Sets whether or not the living entity can pick up items.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.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.Arrow
shootArrow()
Deprecated.use launchProjectile(Arrow.class) insteadEgg
throwEgg()
Deprecated.use launchProjectile(Egg.class) insteadSnowball
throwSnowball()
Deprecated.use launchProjectile(Snowball.class) insteadMethods inherited from interface org.bukkit.entity.Damageable
_INVALID_damage, _INVALID_damage, _INVALID_getHealth, _INVALID_getMaxHealth, _INVALID_setHealth, _INVALID_setMaxHealth, damage, damage, getHealth, getMaxHealth, resetMaxHealth, setHealth, setMaxHealth
Methods inherited from interface org.bukkit.entity.Entity
eject, getCustomName, getEntityId, getFallDistance, getFireTicks, getLastDamageCause, getLocation, getLocation, getMaxFireTicks, getNearbyEntities, getPassenger, getServer, getTicksLived, getType, getUniqueId, getVehicle, getVelocity, getWorld, isCustomNameVisible, isDead, isEmpty, isInsideVehicle, isOnGround, isValid, leaveVehicle, playEffect, remove, setCustomName, setCustomNameVisible, setFallDistance, setFireTicks, setLastDamageCause, setPassenger, 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.permissions.Permissible
addAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, recalculatePermissions, removeAttachment
Methods inherited from interface org.bukkit.projectiles.ProjectileSource
launchProjectile, launchProjectile
-
Method Details
-
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 ignoreSneaking)Gets the height of the living entity's eyes above its Location.- Parameters:
ignoreSneaking
- if set to true, the effects of sneaking will be ignored- Returns:
- height of the living entity's eyes above its location
-
getEyeLocation
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
@Deprecated java.util.List<Block> getLineOfSight(java.util.HashSet<java.lang.Byte> transparent, int maxDistance)Deprecated.Magic valueGets 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.
- Parameters:
transparent
- HashSet containing all transparent block IDs (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
-
getLineOfSight
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.
- 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
Deprecated.Magic valueGets the block that the living entity has targeted.- Parameters:
transparent
- HashSet containing all transparent block IDs (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
-
getTargetBlock
Gets the block that the living entity has targeted.- 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
@Deprecated java.util.List<Block> getLastTwoTargetBlocks(java.util.HashSet<java.lang.Byte> transparent, int maxDistance)Deprecated.Magic valueGets the last two blocks along the living entity's line of sight.The target block will be the last block in the list.
- Parameters:
transparent
- HashSet containing all transparent block IDs (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
-
getLastTwoTargetBlocks
Gets the last two blocks along the living entity's line of sight.The target block will be the last block in the list.
- 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
-
throwEgg
Deprecated.use launchProjectile(Egg.class) insteadThrows an egg from the living entity.- Returns:
- the egg thrown
-
throwSnowball
Deprecated.use launchProjectile(Snowball.class) insteadThrows a snowball from the living entity.- Returns:
- the snowball thrown
-
shootArrow
Deprecated.use launchProjectile(Arrow.class) insteadShoots an arrow from the living entity.- Returns:
- the arrow shot
-
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
-
_INVALID_getLastDamage
@Deprecated int _INVALID_getLastDamage()Deprecated.This method exists for legacy reasons to provide backwards compatibility. It will not exist at runtime and should not be used under any circumstances.- 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
-
_INVALID_setLastDamage
@Deprecated void _INVALID_setLastDamage(int damage)Deprecated.This method exists for legacy reasons to provide backwards compatibility. It will not exist at runtime and should not be used under any circumstances.- 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
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
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
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
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
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
-
removePotionEffect
Removes any effects present of the givenPotionEffectType
.- Parameters:
type
- the potion type to remove
-
getActivePotionEffects
java.util.Collection<PotionEffect> getActivePotionEffects()Returns all currently activePotionEffect
s on the living entity.- Returns:
- a collection of
PotionEffect
s
-
hasLineOfSight
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
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
Gets the entity that is currently leading this entity.- Returns:
- the entity holding the leash
- Throws:
java.lang.IllegalStateException
- if not currently leashed
-
setLeashHolder
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- Returns:
- whether the operation was successful
-