org.bukkit.entity
Interface LivingEntity

All Superinterfaces:
Damageable, Entity, Metadatable, ProjectileSource
All Known Subinterfaces:
Ageable, Ambient, Animals, Bat, Blaze, CaveSpider, Chicken, ComplexLivingEntity, Cow, Creature, Creeper, EnderDragon, Enderman, Flying, Ghast, Giant, Golem, Horse, HumanEntity, IronGolem, MagmaCube, Monster, MushroomCow, NPC, Ocelot, Pig, PigZombie, Player, Sheep, Silverfish, Skeleton, Slime, Snowman, Spider, Squid, Villager, WaterMob, Witch, Wither, Wolf, Zombie

public interface LivingEntity
extends Entity, Damageable, ProjectileSource

Represents a living entity, such as a monster or player


Method Summary
 int _INVALID_getLastDamage()
          Deprecated. 
 void _INVALID_setLastDamage(int damage)
          Deprecated. 
 boolean addPotionEffect(PotionEffect effect)
          Adds the given PotionEffect to the living entity.
 boolean addPotionEffect(PotionEffect effect, boolean force)
          Adds the given PotionEffect to the living entity.
 boolean addPotionEffects(Collection<PotionEffect> effects)
          Attempts to add all of the given PotionEffect to the living entity.
 Collection<PotionEffect> getActivePotionEffects()
          Returns all currently active PotionEffects on the living entity.
 boolean getCanPickupItems()
          Gets if the living entity can pick up items.
 String getCustomName()
          Gets the custom name on a mob.
 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.
 List<Block> getLastTwoTargetBlocks(HashSet<Byte> transparent, int maxDistance)
          Deprecated. Magic value
 Entity getLeashHolder()
          Gets the entity that is currently leading this entity.
 List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance)
          Deprecated. Magic value
 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(HashSet<Byte> transparent, int maxDistance)
          Deprecated. Magic value
 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 given PotionEffectType applied to it.
 boolean isCustomNameVisible()
          Gets whether or not the mob's custom name is displayed client side.
 boolean isLeashed()
          Returns whether the entity is currently leashed.
 void removePotionEffect(PotionEffectType type)
          Removes any effects present of the given PotionEffectType.
 void setCanPickupItems(boolean pickup)
          Sets whether or not the living entity can pick up items.
 void setCustomName(String name)
          Sets a custom name on a mob.
 void setCustomNameVisible(boolean flag)
          Sets whether or not to display the mob's custom name client side.
 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) instead
 Egg throwEgg()
          Deprecated. use launchProjectile(Egg.class) instead
 Snowball throwSnowball()
          Deprecated. use launchProjectile(Snowball.class) instead
 
Methods 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, getEntityId, getFallDistance, getFireTicks, getLastDamageCause, getLocation, getLocation, getMaxFireTicks, getNearbyEntities, getPassenger, getServer, getTicksLived, getType, getUniqueId, getVehicle, getVelocity, getWorld, isDead, isEmpty, isInsideVehicle, isOnGround, isValid, leaveVehicle, playEffect, remove, setFallDistance, setFireTicks, setLastDamageCause, setPassenger, setTicksLived, setVelocity, teleport, teleport, teleport, teleport
 
Methods inherited from interface org.bukkit.metadata.Metadatable
getMetadata, hasMetadata, removeMetadata, setMetadata
 
Methods inherited from interface org.bukkit.projectiles.ProjectileSource
launchProjectile, launchProjectile
 

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 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
List<Block> getLineOfSight(HashSet<Byte> transparent,
                                      int maxDistance)
Deprecated. Magic value

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 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

getTargetBlock

@Deprecated
Block getTargetBlock(HashSet<Byte> transparent,
                                int maxDistance)
Deprecated. Magic value

Gets 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

getLastTwoTargetBlocks

@Deprecated
List<Block> getLastTwoTargetBlocks(HashSet<Byte> transparent,
                                              int maxDistance)
Deprecated. Magic value

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 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

throwEgg

@Deprecated
Egg throwEgg()
Deprecated. use launchProjectile(Egg.class) instead

Throws an egg from the living entity.

Returns:
the egg thrown

throwSnowball

@Deprecated
Snowball throwSnowball()
Deprecated. use launchProjectile(Snowball.class) instead

Throws a snowball from the living entity.

Returns:
the snowball thrown

shootArrow

@Deprecated
Arrow shootArrow()
Deprecated. use launchProjectile(Arrow.class) instead

Shoots 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.


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.


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

boolean addPotionEffect(PotionEffect effect)
Adds the given PotionEffect 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(PotionEffect effect,
                        boolean force)
Adds the given PotionEffect to 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

addPotionEffects

boolean addPotionEffects(Collection<PotionEffect> effects)
Attempts to add all of the given PotionEffect to the living entity.

Parameters:
effects - the effects to add
Returns:
whether all of the effects could be added

hasPotionEffect

boolean hasPotionEffect(PotionEffectType type)
Returns whether the living entity already has an existing effect of the given PotionEffectType applied to it.

Parameters:
type - the potion type to check
Returns:
whether the living entity has this potion effect active on them

removePotionEffect

void removePotionEffect(PotionEffectType type)
Removes any effects present of the given PotionEffectType.

Parameters:
type - the potion type to remove

getActivePotionEffects

Collection<PotionEffect> getActivePotionEffects()
Returns all currently active PotionEffects on the living entity.

Returns:
a collection of PotionEffects

hasLineOfSight

boolean hasLineOfSight(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

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

setCustomName

void setCustomName(String name)
Sets a custom name on a mob. This name will be used in death messages and can be sent to the client as a nameplate over the mob.

Setting the name to null or an empty string will clear it.

This value has no effect on players, they will always use their real name.

Parameters:
name - the name to set

getCustomName

String getCustomName()
Gets the custom name on a mob. If there is no name this method will return null.

This value has no effect on players, they will always use their real name.

Returns:
name of the mob or null

setCustomNameVisible

void setCustomNameVisible(boolean flag)
Sets whether or not to display the mob's custom name client side. The name will be displayed above the mob similarly to a player.

This value has no effect on players, they will always display their name.

Parameters:
flag - custom name or not

isCustomNameVisible

boolean isCustomNameVisible()
Gets whether or not the mob's custom name is displayed client side.

This value has no effect on players, they will always display their name.

Returns:
if the custom name is displayed

isLeashed

boolean isLeashed()
Returns whether the entity is currently leashed.

Returns:
whether the entity is leashed

getLeashHolder

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(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
Returns:
whether the operation was successful


Copyright © 2014. All rights reserved.