Package org.bukkit.entity
Interface Entity
- All Superinterfaces:
CommandSender,Metadatable,Permissible,ServerOperator
- All Known Subinterfaces:
Ageable,Ambient,Animals,ArmorStand,Arrow,Bat,Blaze,Boat,CaveSpider,Chicken,CommandMinecart,ComplexEntityPart,ComplexLivingEntity,Cow,Creature,Creeper,Damageable,Egg,EnderCrystal,EnderDragon,EnderDragonPart,Enderman,Endermite,EnderPearl,EnderSignal,ExperienceOrb,Explosive,ExplosiveMinecart,FallingBlock,FallingSand,Fireball,Firework,Fish,FishHook,Flying,Ghast,Giant,Golem,Guardian,Hanging,HopperMinecart,Horse,HumanEntity,IronGolem,Item,ItemFrame,LargeFireball,LeashHitch,LightningStrike,LivingEntity,MagmaCube,Minecart,Monster,MushroomCow,NPC,Ocelot,Painting,Pig,PigZombie,Player,PoweredMinecart,PoweredMinecart,Projectile,Rabbit,RideableMinecart,Sheep,Silverfish,Skeleton,Slime,SmallFireball,Snowball,Snowman,SpawnerMinecart,Spider,Squid,StorageMinecart,StorageMinecart,ThrownExpBottle,ThrownPotion,TNTPrimed,Vehicle,Villager,WaterMob,Weather,Witch,Wither,WitherSkull,Wolf,Zombie
public interface Entity extends Metadatable, CommandSender
Represents a base entity in the world
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classEntity.Spigot -
Method Summary
Modifier and Type Method Description booleaneject()Eject any passenger.java.lang.StringgetCustomName()Gets the custom name on a mob.intgetEntityId()Returns a unique id for this entityfloatgetFallDistance()Returns the distance this entity has fallenintgetFireTicks()Returns the entity's current fire ticks (ticks before the entity stops being on fire).EntityDamageEventgetLastDamageCause()Retrieve the lastEntityDamageEventinflicted on this entity.LocationgetLocation()Gets the entity's current positionLocationgetLocation(Location loc)Stores the entity's current position in the provided Location object.intgetMaxFireTicks()Returns the entity's maximum fire ticks.java.util.List<Entity>getNearbyEntities(double x, double y, double z)Returns a list of entities within a bounding box centered around this entityEntitygetPassenger()Gets the primary passenger of a vehicle.ServergetServer()Gets theServerthat contains this EntityintgetTicksLived()Gets the amount of ticks this entity has lived for.EntityTypegetType()Get the type of the entity.java.util.UUIDgetUniqueId()Returns a unique and persistent id for this entityEntitygetVehicle()Get the vehicle that this player is inside.VectorgetVelocity()Gets this entity's current velocityWorldgetWorld()Gets the current world this entity resides inbooleanisCustomNameVisible()Gets whether or not the mob's custom name is displayed client side.booleanisDead()Returns true if this entity has been marked for removal.booleanisEmpty()Check if a vehicle has passengers.booleanisInsideVehicle()Returns whether this entity is inside a vehicle.booleanisOnGround()Returns true if the entity is supported by a block.booleanisValid()Returns false if the entity has died or been despawned for some other reason.booleanleaveVehicle()Leave the current vehicle.voidplayEffect(EntityEffect type)Performs the specifiedEntityEffectfor this entity.voidremove()Mark the entity's removal.voidsetCustomName(java.lang.String name)Sets a custom name on a mob.voidsetCustomNameVisible(boolean flag)Sets whether or not to display the mob's custom name client side.voidsetFallDistance(float distance)Sets the fall distance for this entityvoidsetFireTicks(int ticks)Sets the entity's current fire ticks (ticks before the entity stops being on fire).voidsetLastDamageCause(EntityDamageEvent event)Record the lastEntityDamageEventinflicted on this entitybooleansetPassenger(Entity passenger)Set the passenger of a vehicle.voidsetTicksLived(int value)Sets the amount of ticks this entity has lived for.voidsetVelocity(Vector velocity)Sets this entity's velocityEntity.Spigotspigot()booleanteleport(Entity destination)Teleports this entity to the target Entity.booleanteleport(Entity destination, PlayerTeleportEvent.TeleportCause cause)Teleports this entity to the target Entity.booleanteleport(Location location)Teleports this entity to the given location.booleanteleport(Location location, PlayerTeleportEvent.TeleportCause cause)Teleports this entity to the given location.Methods 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, removeAttachment
-
Method Details
-
getLocation
Location getLocation()Gets the entity's current position- Returns:
- a new copy of Location containing the position of this entity
-
getLocation
Stores the entity's current position in the provided Location object.If the provided Location is null this method does nothing and returns null.
- Parameters:
loc- the location to copy into- Returns:
- The Location object provided or null
-
setVelocity
Sets this entity's velocity- Parameters:
velocity- New velocity to travel with
-
getVelocity
Vector getVelocity()Gets this entity's current velocity- Returns:
- Current travelling velocity of this entity
-
isOnGround
boolean isOnGround()Returns true if the entity is supported by a block. This value is a state updated by the server and is not recalculated unless the entity moves.- Returns:
- True if entity is on ground.
-
getWorld
World getWorld()Gets the current world this entity resides in- Returns:
- World
-
teleport
Teleports this entity to the given location. If this entity is riding a vehicle, it will be dismounted prior to teleportation.- Parameters:
location- New location to teleport this entity to- Returns:
trueif the teleport was successful
-
teleport
Teleports this entity to the given location. If this entity is riding a vehicle, it will be dismounted prior to teleportation.- Parameters:
location- New location to teleport this entity tocause- The cause of this teleportation- Returns:
trueif the teleport was successful
-
teleport
Teleports this entity to the target Entity. If this entity is riding a vehicle, it will be dismounted prior to teleportation.- Parameters:
destination- Entity to teleport this entity to- Returns:
trueif the teleport was successful
-
teleport
Teleports this entity to the target Entity. If this entity is riding a vehicle, it will be dismounted prior to teleportation.- Parameters:
destination- Entity to teleport this entity tocause- The cause of this teleportation- Returns:
trueif the teleport was successful
-
getNearbyEntities
Returns a list of entities within a bounding box centered around this entity- Parameters:
x- 1/2 the size of the box along x axisy- 1/2 the size of the box along y axisz- 1/2 the size of the box along z axis- Returns:
List<Entity>List of entities nearby
-
getEntityId
int getEntityId()Returns a unique id for this entity- Returns:
- Entity id
-
getFireTicks
int getFireTicks()Returns the entity's current fire ticks (ticks before the entity stops being on fire).- Returns:
- int fireTicks
-
getMaxFireTicks
int getMaxFireTicks()Returns the entity's maximum fire ticks.- Returns:
- int maxFireTicks
-
setFireTicks
void setFireTicks(int ticks)Sets the entity's current fire ticks (ticks before the entity stops being on fire).- Parameters:
ticks- Current ticks remaining
-
remove
void remove()Mark the entity's removal. -
isDead
boolean isDead()Returns true if this entity has been marked for removal.- Returns:
- True if it is dead.
-
isValid
boolean isValid()Returns false if the entity has died or been despawned for some other reason.- Returns:
- True if valid.
-
getServer
Server getServer()Gets theServerthat contains this Entity- Specified by:
getServerin interfaceCommandSender- Returns:
- Server instance running this Entity
-
getPassenger
Entity getPassenger()Gets the primary passenger of a vehicle. For vehicles that could have multiple passengers, this will only return the primary passenger.- Returns:
- an entity
-
setPassenger
Set the passenger of a vehicle.- Parameters:
passenger- The new passenger.- Returns:
- false if it could not be done for whatever reason
-
isEmpty
boolean isEmpty()Check if a vehicle has passengers.- Returns:
- True if the vehicle has no passengers.
-
eject
boolean eject()Eject any passenger.- Returns:
- True if there was a passenger.
-
getFallDistance
float getFallDistance()Returns the distance this entity has fallen- Returns:
- The distance.
-
setFallDistance
void setFallDistance(float distance)Sets the fall distance for this entity- Parameters:
distance- The new distance.
-
setLastDamageCause
Record the lastEntityDamageEventinflicted on this entity- Parameters:
event- aEntityDamageEvent
-
getLastDamageCause
EntityDamageEvent getLastDamageCause()Retrieve the lastEntityDamageEventinflicted on this entity. This event may have been cancelled.- Returns:
- the last known
EntityDamageEventor null if hitherto unharmed
-
getUniqueId
java.util.UUID getUniqueId()Returns a unique and persistent id for this entity- Returns:
- unique id
-
getTicksLived
int getTicksLived()Gets the amount of ticks this entity has lived for.This is the equivalent to "age" in entities.
- Returns:
- Age of entity
-
setTicksLived
void setTicksLived(int value)Sets the amount of ticks this entity has lived for.This is the equivalent to "age" in entities. May not be less than one tick.
- Parameters:
value- Age of entity
-
playEffect
Performs the specifiedEntityEffectfor this entity.This will be viewable to all players near the entity.
- Parameters:
type- Effect to play.
-
getType
EntityType getType()Get the type of the entity.- Returns:
- The entity type.
-
isInsideVehicle
boolean isInsideVehicle()Returns whether this entity is inside a vehicle.- Returns:
- True if the entity is in a vehicle.
-
leaveVehicle
boolean leaveVehicle()Leave the current vehicle. If the entity is currently in a vehicle (and is removed from it), true will be returned, otherwise false will be returned.- Returns:
- True if the entity was in a vehicle.
-
getVehicle
Entity getVehicle()Get the vehicle that this player is inside. If there is no vehicle, null will be returned.- Returns:
- The current vehicle.
-
setCustomName
void setCustomName(java.lang.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
java.lang.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
-
spigot
Entity.Spigot spigot()
-