org.bukkit.entity
Interface LivingEntity

All Superinterfaces:
Damageable, Entity, Metadatable
All Known Subinterfaces:
Ageable, Ambient, Animals, Bat, Blaze, CaveSpider, Chicken, ComplexLivingEntity, Cow, Creature, Creeper, EnderDragon, Enderman, Flying, Ghast, Giant, Golem, 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

Represents a living entity, such as a monster or player


Method Summary
 boolean addPotionEffect(PotionEffect effect)
          Adds the given PotionEffect to this entity.
 boolean addPotionEffect(PotionEffect effect, boolean force)
          Adds the given PotionEffect to this entity.
 boolean addPotionEffects(Collection<PotionEffect> effects)
          Attempts to add all of the given PotionEffect to this entity.
 Collection<PotionEffect> getActivePotionEffects()
          Returns all currently active PotionEffects on this entity.
 boolean getCanPickupItems()
          Gets if the entity can pick up items
 String getCustomName()
          Gets the custom name on a mob.
 EntityEquipment getEquipment()
          Gets the inventory with the equipment worn by this entity.
 double getEyeHeight()
          Gets the height of the entity's head above its Location
 double getEyeHeight(boolean ignoreSneaking)
          Gets the height of the entity's head above its Location
 Location getEyeLocation()
          Get a Location detailing the current eye position of the LivingEntity.
 Player getKiller()
          Gets the player identified as the killer of this entity.
 int getLastDamage()
          Returns the entities lastDamage taken in the current noDamageTicks time.
 List<Block> getLastTwoTargetBlocks(HashSet<Byte> transparent, int maxDistance)
          Gets the last two blocks along the player's line of sight.
 List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance)
          Gets all blocks along the player's line of sight List iterates from player's position to target inclusive
 int getMaximumAir()
          Returns the maximum amount of air this entity can have, in ticks
 int getMaximumNoDamageTicks()
          Returns the entities current maximum noDamageTicks This is the time in ticks the entity will become unable to take equal or less damage than the lastDamage
 int getNoDamageTicks()
          Returns the entities current noDamageTicks
 int getRemainingAir()
          Returns the amount of air that this entity has remaining, in ticks
 boolean getRemoveWhenFarAway()
          Returns if the entity despawns when away from players or not.
By default animals are not removed while other mobs are.
 Block getTargetBlock(HashSet<Byte> transparent, int maxDistance)
          Gets the block that the player has targeted
 boolean hasLineOfSight(Entity other)
          Checks whether the entity has block line of sight to another.
This uses the same algorithm that hostile mobs use to find the closest player.
 boolean hasPotionEffect(PotionEffectType type)
          Returns whether the 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.
<T extends Projectile>
T
launchProjectile(Class<? extends T> projectile)
          Launches a Projectile from the entity.
 void removePotionEffect(PotionEffectType type)
          Removes any effects present of the given PotionEffectType.
 void setCanPickupItems(boolean pickup)
          Sets whether or not the 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(int damage)
          Sets the entities current maximum noDamageTicks
 void setMaximumAir(int ticks)
          Sets the maximum amount of air this entity can have, in ticks
 void setMaximumNoDamageTicks(int ticks)
          Sets the entities current maximum noDamageTicks
 void setNoDamageTicks(int ticks)
          Sets the entities current noDamageTicks
 void setRemainingAir(int ticks)
          Sets the amount of air that this entity has remaining, in ticks
 void setRemoveWhenFarAway(boolean remove)
          Sets whether or not the 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
damage, damage, getHealth, getMaxHealth, resetMaxHealth, setHealth, setMaxHealth
 

Method Detail

getEyeHeight

double getEyeHeight()
Gets the height of the entity's head above its Location

Returns:
Height of the entity's eyes above its Location

getEyeHeight

double getEyeHeight(boolean ignoreSneaking)
Gets the height of the entity's head above its Location

Parameters:
ignoreSneaking - If set to true, the effects of sneaking will be ignored
Returns:
Height of the entity's eyes above its Location

getEyeLocation

Location getEyeLocation()
Get a Location detailing the current eye position of the LivingEntity.

Returns:
a Location at the eyes of the LivingEntity.

getLineOfSight

List<Block> getLineOfSight(HashSet<Byte> transparent,
                           int maxDistance)
Gets all blocks along the player's line of sight List iterates from player's position to target inclusive

Parameters:
transparent - HashSet containing all transparent block IDs. If set to null only air is considered transparent.
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 all blocks along the player's line of sight

getTargetBlock

Block getTargetBlock(HashSet<Byte> transparent,
                     int maxDistance)
Gets the block that the player has targeted

Parameters:
transparent - HashSet containing all transparent block IDs. If set to null only air is considered transparent.
maxDistance - This is the maximum distance to scan. This may be further limited by the server, but never to less than 100 blocks.
Returns:
Block that the player has targeted

getLastTwoTargetBlocks

List<Block> getLastTwoTargetBlocks(HashSet<Byte> transparent,
                                   int maxDistance)
Gets the last two blocks along the player's line of sight. The target block will be the last block in the list.

Parameters:
transparent - HashSet containing all transparent block IDs. If set to null only air is considered transparent.
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 player's line of sight

throwEgg

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

Throws an egg from the entity.

Returns:
The egg thrown.

throwSnowball

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

Throws a snowball from the entity.

Returns:
The snowball thrown.

shootArrow

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

Shoots an arrow from the entity.

Returns:
The arrow shot.

launchProjectile

<T extends Projectile> T launchProjectile(Class<? extends T> projectile)
Launches a Projectile from the entity.

Parameters:
projectile - Class of the projectile to launch
Returns:
The launched projectile.

getRemainingAir

int getRemainingAir()
Returns the amount of air that this entity has remaining, in ticks

Returns:
Amount of air remaining

setRemainingAir

void setRemainingAir(int ticks)
Sets the amount of air that this entity has remaining, in ticks

Parameters:
ticks - Amount of air remaining

getMaximumAir

int getMaximumAir()
Returns the maximum amount of air this entity can have, in ticks

Returns:
Maximum amount of air

setMaximumAir

void setMaximumAir(int ticks)
Sets the maximum amount of air this entity can have, in ticks

Parameters:
ticks - Maximum amount of air

getMaximumNoDamageTicks

int getMaximumNoDamageTicks()
Returns the entities current maximum noDamageTicks This is the time in ticks the entity will become unable to take equal or less damage than the lastDamage

Returns:
noDamageTicks

setMaximumNoDamageTicks

void setMaximumNoDamageTicks(int ticks)
Sets the entities current maximum noDamageTicks

Parameters:
ticks - maximumNoDamageTicks

getLastDamage

int getLastDamage()
Returns the entities lastDamage taken in the current noDamageTicks time. Only damage higher than this amount will further damage the entity.

Returns:
lastDamage

setLastDamage

void setLastDamage(int damage)
Sets the entities current maximum noDamageTicks

Parameters:
damage - last damage

getNoDamageTicks

int getNoDamageTicks()
Returns the entities current noDamageTicks

Returns:
noDamageTicks

setNoDamageTicks

void setNoDamageTicks(int ticks)
Sets the entities current noDamageTicks

Parameters:
ticks - NoDamageTicks

getKiller

Player getKiller()
Gets the player identified as the killer of this entity.

May be null.

Returns:
Killer player, or null if none found.

addPotionEffect

boolean addPotionEffect(PotionEffect effect)
Adds the given PotionEffect to this 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 this 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 this entity.

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

hasPotionEffect

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

Parameters:
type - The potion type to check
Returns:
Whether the player 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 this entity.

Returns:
A collection of PotionEffects

hasLineOfSight

boolean hasLineOfSight(Entity other)
Checks whether the 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 entity despawns when away from players or not.
By default animals are not removed while other mobs are.

Returns:
true if the entity is removed when away from players

setRemoveWhenFarAway

void setRemoveWhenFarAway(boolean remove)
Sets whether or not the entity despawns when away from players or not.

Parameters:
remove - The remove status

getEquipment

EntityEquipment getEquipment()
Gets the inventory with the equipment worn by this entity.

Returns:
the entities inventory.

setCanPickupItems

void setCanPickupItems(boolean pickup)
Sets whether or not the entity can pick up items

Parameters:
pickup - Whether or not the entity can pick up items

getCanPickupItems

boolean getCanPickupItems()
Gets if the entity can pick up items

Returns:
whether or not the 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 - 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 - show custom name

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


Copyright © 2013. All Rights Reserved.