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.booleanaddPotionEffect(PotionEffect effect)Adds the givenPotionEffectto the living entity.booleanaddPotionEffect(PotionEffect effect, boolean force)Adds the givenPotionEffectto the living entity.booleanaddPotionEffects(java.util.Collection<PotionEffect> effects)Attempts to add all of the givenPotionEffectto the living entity.java.util.Collection<PotionEffect>getActivePotionEffects()Returns all currently activePotionEffects on the living entity.booleangetCanPickupItems()Gets if the living entity can pick up items.EntityEquipmentgetEquipment()Gets the inventory with the equipment worn by the living entity.doublegetEyeHeight()Gets the height of the living entity's eyes above its Location.doublegetEyeHeight(boolean ignoreSneaking)Gets the height of the living entity's eyes above its Location.LocationgetEyeLocation()Get a Location detailing the current eye position of the living entity.PlayergetKiller()Gets the player identified as the killer of the living entity.doublegetLastDamage()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.EntitygetLeashHolder()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.intgetMaximumAir()Returns the maximum amount of air the living entity can have, in ticks.intgetMaximumNoDamageTicks()Returns the living entity's current maximum no damage ticks.intgetNoDamageTicks()Returns the living entity's current no damage ticks.intgetRemainingAir()Returns the amount of air that the living entity has remaining, in ticks.booleangetRemoveWhenFarAway()Returns if the living entity despawns when away from players or not.BlockgetTargetBlock(java.util.HashSet<java.lang.Byte> transparent, int maxDistance)Deprecated.Magic valueBlockgetTargetBlock(java.util.Set<Material> transparent, int maxDistance)Gets the block that the living entity has targeted.booleanhasLineOfSight(Entity other)Checks whether the living entity has block line of sight to another.booleanhasPotionEffect(PotionEffectType type)Returns whether the living entity already has an existing effect of the givenPotionEffectTypeapplied to it.booleanisLeashed()Returns whether the entity is currently leashed.voidremovePotionEffect(PotionEffectType type)Removes any effects present of the givenPotionEffectType.voidsetCanPickupItems(boolean pickup)Sets whether or not the living entity can pick up items.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.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.ArrowshootArrow()Deprecated.use launchProjectile(Arrow.class) insteadEggthrowEgg()Deprecated.use launchProjectile(Egg.class) insteadSnowballthrowSnowball()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, setMaxHealthMethods 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, teleportMethods inherited from interface org.bukkit.metadata.Metadatable
getMetadata, hasMetadata, removeMetadata, setMetadataMethods inherited from interface org.bukkit.permissions.Permissible
addAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, recalculatePermissions, removeAttachmentMethods 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 givenPotionEffectto 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 givenPotionEffectto 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 givenPotionEffectto 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 givenPotionEffectTypeapplied 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 activePotionEffects on the living entity.- Returns:
- a collection of
PotionEffects
-
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
-