Interface Entity
- All Superinterfaces:
CommandSender
,Metadatable
,Nameable
,Permissible
,PersistentDataHolder
,ServerOperator
- All Known Subinterfaces:
AbstractArrow
,AbstractHorse
,AbstractVillager
,Ageable
,Ambient
,Animals
,AreaEffectCloud
,ArmorStand
,Arrow
,Bat
,Bee
,Blaze
,Boat
,Boss
,Breedable
,Cat
,CaveSpider
,ChestedHorse
,Chicken
,Cod
,CommandMinecart
,ComplexEntityPart
,ComplexLivingEntity
,Cow
,Creature
,Creeper
,Damageable
,Dolphin
,Donkey
,DragonFireball
,Drowned
,Egg
,ElderGuardian
,EnderCrystal
,EnderDragon
,EnderDragonPart
,Enderman
,Endermite
,EnderPearl
,EnderSignal
,Evoker
,EvokerFangs
,ExperienceOrb
,Explosive
,ExplosiveMinecart
,FallingBlock
,Fireball
,Firework
,Fish
,FishHook
,Flying
,Fox
,Ghast
,Giant
,Golem
,Guardian
,Hanging
,Hoglin
,HopperMinecart
,Horse
,HumanEntity
,Husk
,Illager
,Illusioner
,IronGolem
,Item
,ItemFrame
,LargeFireball
,LeashHitch
,LightningStrike
,LingeringPotion
,LivingEntity
,Llama
,LlamaSpit
,MagmaCube
,Minecart
,Mob
,Monster
,Mule
,MushroomCow
,NPC
,Ocelot
,Painting
,Panda
,Parrot
,Phantom
,Pig
,Piglin
,PiglinAbstract
,PiglinBrute
,PigZombie
,Pillager
,Player
,PolarBear
,PoweredMinecart
,Projectile
,PufferFish
,Rabbit
,Raider
,Ravager
,RideableMinecart
,Salmon
,Sheep
,Shulker
,ShulkerBullet
,Silverfish
,SizedFireball
,Skeleton
,SkeletonHorse
,Slime
,SmallFireball
,Snowball
,Snowman
,SpawnerMinecart
,SpectralArrow
,Spellcaster
,Spider
,SplashPotion
,Squid
,Steerable
,StorageMinecart
,Stray
,Strider
,Tameable
,ThrowableProjectile
,ThrownExpBottle
,ThrownPotion
,TippedArrow
,TNTPrimed
,TraderLlama
,Trident
,TropicalFish
,Turtle
,Vehicle
,Vex
,Villager
,Vindicator
,WanderingTrader
,WaterMob
,Witch
,Wither
,WitherSkeleton
,WitherSkull
,Wolf
,Zoglin
,Zombie
,ZombieHorse
,ZombieVillager
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addPassenger(Entity passenger)
Add a passenger to the vehicle.boolean
addScoreboardTag(String tag)
Add a tag to this entity.boolean
eject()
Eject any passenger.Gets the entity's current bounding box.int
Returns a unique id for this entityGet the closest cardinalBlockFace
direction an entity is currently facing.float
Returns the distance this entity has fallenint
Returns the entity's current fire ticks (ticks before the entity stops being on fire).double
Gets the entity's heightRetrieve the lastEntityDamageEvent
inflicted on this entity.Gets the entity's current positiongetLocation(Location loc)
Stores the entity's current position in the provided Location object.int
Returns the entity's maximum fire ticks.getNearbyEntities(double x, double y, double z)
Returns a list of entities within a bounding box centered around this entityDeprecated.Gets a list of passengers of this vehicle.Returns the reaction of the entity when moved by a piston.int
Gets the period of time (in ticks) before this entity can use a portal.getPose()
Gets the entity's current pose.Returns a set of tags for this entity.Gets theServer
that contains this Entityint
Gets the amount of ticks this entity has lived for.getType()
Get the type of the entity.Returns a unique and persistent id for this entityGet the vehicle that this player is inside.Gets this entity's current velocitydouble
getWidth()
Gets the entity's widthgetWorld()
Gets the current world this entity resides inboolean
Returns whether gravity applies to this entity.boolean
Gets whether or not the mob's custom name is displayed client side.boolean
isDead()
Returns true if this entity has been marked for removal.boolean
isEmpty()
Check if a vehicle has passengers.boolean
Gets whether the entity is glowing or not.boolean
Returns whether this entity is inside a vehicle.boolean
Gets whether the entity is invulnerable or not.boolean
Returns true if the entity is in water.boolean
Returns true if the entity is supported by a block.boolean
Returns true if the entity gets persisted.boolean
isSilent()
Gets whether the entity is silent or not.boolean
isValid()
Returns false if the entity has died or been despawned for some other reason.boolean
Leave the current vehicle.void
playEffect(EntityEffect type)
Performs the specifiedEntityEffect
for this entity.void
remove()
Mark the entity's removal.boolean
removePassenger(Entity passenger)
Remove a passenger from the vehicle.boolean
removeScoreboardTag(String tag)
Removes a given tag from this entity.void
setCustomNameVisible(boolean flag)
Sets whether or not to display the mob's custom name client side.void
setFallDistance(float distance)
Sets the fall distance for this entityvoid
setFireTicks(int ticks)
Sets the entity's current fire ticks (ticks before the entity stops being on fire).void
setGlowing(boolean flag)
Sets whether the entity has a team colored (default: white) glow.void
setGravity(boolean gravity)
Sets whether gravity applies to this entity.void
setInvulnerable(boolean flag)
Sets whether the entity is invulnerable or not.void
setLastDamageCause(EntityDamageEvent event)
Record the lastEntityDamageEvent
inflicted on this entityboolean
setPassenger(Entity passenger)
Deprecated.entities may have multiple passengers, useaddPassenger(org.bukkit.entity.Entity)
void
setPersistent(boolean persistent)
Sets whether or not the entity gets persisted.void
setPortalCooldown(int cooldown)
Sets the period of time (in ticks) before this entity can use a portal.void
setRotation(float yaw, float pitch)
Sets the entity's rotation.void
setSilent(boolean flag)
Sets whether the entity is silent or not.void
setTicksLived(int value)
Sets the amount of ticks this entity has lived for.void
setVelocity(Vector velocity)
Sets this entity's velocity in meters per tickspigot()
boolean
Teleports this entity to the target Entity.boolean
teleport(Entity destination, PlayerTeleportEvent.TeleportCause cause)
Teleports this entity to the target Entity.boolean
Teleports this entity to the given location.boolean
teleport(Location location, PlayerTeleportEvent.TeleportCause cause)
Teleports this entity to the given location.Methods inherited from interface org.bukkit.command.CommandSender
getName, sendMessage, sendMessage, sendMessage, sendMessage
Methods inherited from interface org.bukkit.metadata.Metadatable
getMetadata, hasMetadata, removeMetadata, setMetadata
Methods inherited from interface org.bukkit.Nameable
getCustomName, setCustomName
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.persistence.PersistentDataHolder
getPersistentDataContainer
Methods inherited from interface org.bukkit.permissions.ServerOperator
isOp, setOp
-
Method Details
-
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 in meters per tick- Parameters:
velocity
- New velocity to travel with
-
getVelocity
Gets this entity's current velocity- Returns:
- Current traveling velocity of this entity
-
getHeight
double getHeight()Gets the entity's height- Returns:
- height of entity
-
getWidth
double getWidth()Gets the entity's width- Returns:
- width of entity
-
getBoundingBox
Gets the entity's current bounding box.The returned bounding box reflects the entity's current location and size.
- Returns:
- the entity's current bounding box
-
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.
- See Also:
Player.isOnGround()
-
isInWater
boolean isInWater()Returns true if the entity is in water.- Returns:
true
if the entity is in water.
-
getWorld
Gets the current world this entity resides in- Returns:
- World
-
setRotation
void setRotation(float yaw, float pitch)Sets the entity's rotation.Note that if the entity is affected by AI, it may override this rotation.
- Parameters:
yaw
- the yawpitch
- the pitch- Throws:
UnsupportedOperationException
- if used for players
-
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:
true
if 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:
true
if 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:
true
if 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:
true
if 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
Gets theServer
that contains this Entity- Specified by:
getServer
in interfaceCommandSender
- Returns:
- Server instance running this Entity
-
isPersistent
boolean isPersistent()Returns true if the entity gets persisted.By default all entities are persistent. An entity will also not get persisted, if it is riding an entity that is not persistent.
The persistent flag on players controls whether or not to save their playerdata file when they quit. If a player is directly or indirectly riding a non-persistent entity, the vehicle at the root and all its passengers won't get persisted.
This should not be confused with
LivingEntity.setRemoveWhenFarAway(boolean)
which controls despawning of living entities.- Returns:
- true if this entity is persistent
-
setPersistent
void setPersistent(boolean persistent)Sets whether or not the entity gets persisted.- Parameters:
persistent
- the persistence status- See Also:
isPersistent()
-
getPassenger
Deprecated.entities may have multiple passengers, usegetPassengers()
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
Deprecated.entities may have multiple passengers, useaddPassenger(org.bukkit.entity.Entity)
Set the passenger of a vehicle.- Parameters:
passenger
- The new passenger.- Returns:
- false if it could not be done for whatever reason
-
getPassengers
Gets a list of passengers of this vehicle.The returned list will not be directly linked to the entity's current passengers, and no guarantees are made as to its mutability.
- Returns:
- list of entities corresponding to current passengers.
-
addPassenger
Add a passenger to the vehicle.- Parameters:
passenger
- The passenger to add- Returns:
- false if it could not be done for whatever reason
-
removePassenger
Remove a passenger from the vehicle.- Parameters:
passenger
- The passenger to remove- 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 lastEntityDamageEvent
inflicted on this entity- Parameters:
event
- aEntityDamageEvent
-
getLastDamageCause
Retrieve the lastEntityDamageEvent
inflicted on this entity. This event may have been cancelled.- Returns:
- the last known
EntityDamageEvent
or null if hitherto unharmed
-
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 specifiedEntityEffect
for this entity.This will be viewable to all players near the entity.
If the effect is not applicable to this class of entity, it will not play.
- Parameters:
type
- Effect to play.
-
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
Get the vehicle that this player is inside. If there is no vehicle, null will be returned.- Returns:
- The current vehicle.
-
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
-
setGlowing
void setGlowing(boolean flag)Sets whether the entity has a team colored (default: white) glow. nb: this refers to the 'Glowing' entity property, not whether a glowing potion effect is applied- Parameters:
flag
- if the entity is glowing
-
isGlowing
boolean isGlowing()Gets whether the entity is glowing or not. nb: this refers to the 'Glowing' entity property, not whether a glowing potion effect is applied- Returns:
- whether the entity is glowing
-
setInvulnerable
void setInvulnerable(boolean flag)Sets whether the entity is invulnerable or not.When an entity is invulnerable it can only be damaged by players in creative mode.
- Parameters:
flag
- if the entity is invulnerable
-
isInvulnerable
boolean isInvulnerable()Gets whether the entity is invulnerable or not.- Returns:
- whether the entity is
-
isSilent
boolean isSilent()Gets whether the entity is silent or not.- Returns:
- whether the entity is silent.
-
setSilent
void setSilent(boolean flag)Sets whether the entity is silent or not.When an entity is silent it will not produce any sound.
- Parameters:
flag
- if the entity is silent
-
hasGravity
boolean hasGravity()Returns whether gravity applies to this entity.- Returns:
- whether gravity applies
-
setGravity
void setGravity(boolean gravity)Sets whether gravity applies to this entity.- Parameters:
gravity
- whether gravity should apply
-
getPortalCooldown
int getPortalCooldown()Gets the period of time (in ticks) before this entity can use a portal.- Returns:
- portal cooldown ticks
-
setPortalCooldown
void setPortalCooldown(int cooldown)Sets the period of time (in ticks) before this entity can use a portal.- Parameters:
cooldown
- portal cooldown ticks
-
getScoreboardTags
Returns a set of tags for this entity.
Entities can have no more than 1024 tags.- Returns:
- a set of tags for this entity
-
addScoreboardTag
Add a tag to this entity.
Entities can have no more than 1024 tags.- Parameters:
tag
- the tag to add- Returns:
- true if the tag was successfully added
-
removeScoreboardTag
Removes a given tag from this entity.- Parameters:
tag
- the tag to remove- Returns:
- true if the tag was successfully removed
-
getPistonMoveReaction
Returns the reaction of the entity when moved by a piston.- Returns:
- reaction
-
getFacing
Get the closest cardinalBlockFace
direction an entity is currently facing.
This will not return any non-cardinal directions such asBlockFace.UP
orBlockFace.DOWN
.
Hanging
entities will override this call and thus their behavior may be different.- Returns:
- the entity's current cardinal facing.
- See Also:
Hanging
,Directional.getFacing()
-
getPose
Gets the entity's current pose. Note that the pose is only updated at the end of a tick, so may be inconsistent with other methods. egPlayer.isSneaking()
being true does not imply the current pose will bePose.SNEAKING
- Returns:
- current pose
-
spigot
- Specified by:
spigot
in interfaceCommandSender
-
getPassengers()