Interface Entity
- All Superinterfaces:
Audience
,CommandSender
,HoverEventSource<HoverEvent.ShowEntity>
,Metadatable
,Nameable
,Permissible
,PersistentDataHolder
,PersistentDataViewHolder
,Pointered
,ServerOperator
,Sound.Emitter
- All Known Subinterfaces:
AbstractArrow
,AbstractHorse
,AbstractSkeleton
,AbstractVillager
,AbstractWindCharge
,AcaciaBoat
,AcaciaChestBoat
,Ageable
,Allay
,Ambient
,Animals
,AreaEffectCloud
,Armadillo
,ArmorStand
,Arrow
,Axolotl
,BambooChestRaft
,BambooRaft
,Bat
,Bee
,BirchBoat
,BirchChestBoat
,Blaze
,BlockDisplay
,Boat
,Bogged
,Boss
,Breedable
,Breeze
,BreezeWindCharge
,Bucketable
,Camel
,Cat
,CaveSpider
,CherryBoat
,CherryChestBoat
,ChestBoat
,ChestedHorse
,Chicken
,Cod
,CollarColorable
,CommandMinecart
,ComplexEntityPart
,ComplexLivingEntity
,Cow
,Creaking
,CreakingTransient
,Creature
,Creeper
,Damageable
,DarkOakBoat
,DarkOakChestBoat
,Display
,Dolphin
,Donkey
,DragonFireball
,Drowned
,Egg
,ElderGuardian
,EnderCrystal
,EnderDragon
,EnderDragonPart
,Enderman
,Endermite
,EnderPearl
,EnderSignal
,Enemy
,Evoker
,EvokerFangs
,ExperienceOrb
,Explosive
,ExplosiveMinecart
,FallingBlock
,Fireball
,Firework
,Fish
,FishHook
,Flying
,Fox
,Frog
,Ghast
,Giant
,GlowItemFrame
,GlowSquid
,Goat
,Golem
,Guardian
,Hanging
,Hoglin
,HopperMinecart
,Horse
,HumanEntity
,Husk
,Illager
,Illusioner
,Interaction
,IronGolem
,Item
,ItemDisplay
,ItemFrame
,JungleBoat
,JungleChestBoat
,LargeFireball
,Leashable
,LeashHitch
,LightningStrike
,LingeringPotion
,LivingEntity
,Llama
,LlamaSpit
,MagmaCube
,MangroveBoat
,MangroveChestBoat
,Marker
,Minecart
,Mob
,Monster
,Mule
,MushroomCow
,NPC
,OakBoat
,OakChestBoat
,Ocelot
,OminousItemSpawner
,Painting
,PaleOakBoat
,PaleOakChestBoat
,Panda
,Parrot
,Phantom
,Pig
,Piglin
,PiglinAbstract
,PiglinBrute
,PigZombie
,Pillager
,Player
,PolarBear
,PoweredMinecart
,Projectile
,PufferFish
,Rabbit
,Raider
,RangedEntity
,Ravager
,RideableMinecart
,Salmon
,SchoolableFish
,Shearable
,Sheep
,Shulker
,ShulkerBullet
,Silverfish
,SizedFireball
,Skeleton
,SkeletonHorse
,Slime
,SmallFireball
,Sniffer
,Snowball
,Snowman
,SpawnerMinecart
,SpectralArrow
,Spellcaster
,Spider
,SplashPotion
,SpruceBoat
,SpruceChestBoat
,Squid
,Steerable
,StorageMinecart
,Stray
,Strider
,Tadpole
,Tameable
,TextDisplay
,ThrowableProjectile
,ThrownExpBottle
,ThrownPotion
,TippedArrow
,TNTPrimed
,TraderLlama
,Trident
,TropicalFish
,Turtle
,Vehicle
,Vex
,Villager
,Vindicator
,WanderingTrader
,Warden
,WaterMob
,WindCharge
,Witch
,Wither
,WitherSkeleton
,WitherSkull
,Wolf
,Zoglin
,Zombie
,ZombieHorse
,ZombieVillager
Not all methods are guaranteed to work/may have side effects when
isInWorld()
is false.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addPassenger
(@NotNull Entity passenger) Add a passenger to the vehicle.boolean
Add a tag to this entity.default HoverEvent
<HoverEvent.ShowEntity> Creates a hover event with value derived from this object.void
broadcastHurtAnimation
(Collection<Player> players) Broadcasts a hurt animation.boolean
collidesAt
(@NotNull Location location) Checks for any collisions with the entity's bounding box at the provided location.copy()
Creates a copy of this entity and all its data.Creates a copy of this entity and all its data.Crates anEntitySnapshot
representing the current state of this entity.boolean
eject()
Eject any passenger.boolean
Returns whether this entity was spawned from a mob spawner.Get this entity as an NBT string.Gets the entity's current bounding box.getChunk()
Gets the latest chunk an entity is currently or was in.int
Returns the network protocol ID for this entity.Get 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).int
Returns the entity's current freeze ticks (amount of ticks the entity has been in powdered snow).double
Gets the entity's heightRetrieve the lastEntityDamageEvent
inflicted on this entity.Gets the entity's current positiongetLocation
(@Nullable Location loc) Stores the entity's current position in the provided Location object.int
Returns the entity's maximum fire ticks.int
Returns the entity's maximum freeze ticks (amount of ticks before it will be fully frozen)getNearbyEntities
(double x, double y, double z) Returns a list of entities within a bounding box centered around this entityGets the location where this entity originates from.Deprecated.Gets a list of passengers of this vehicle.Returns the reaction of the entity when moved by a piston.float
getPitch()
Gets this entity's pitchint
Gets the period of time (in ticks) before this entity can use a portal.getPose()
Gets the entity's current pose.Returns the task scheduler for this entity.Gets the string name of the entity used to track it inScoreboards
.Returns a set of tags for this entity.Gets theServer
that contains this EntityGet the category of spawn to which this entity belongs.Get theSound
this entity makes when splashing in water at high speeds.Get theSound
this entity makes while swimming.Get theSound
this entity makes when splashing in water.int
Gets the amount of ticks this entity has lived for.Get all players that are currently tracking this entity.Deprecated.slightly misleading name, usegetTrackedBy()
getType()
Get the type of the entity.Returns a unique and persistent id for this entityGet the vehicle that this entity is inside.Gets this entity's current velocitydouble
getWidth()
Gets the entity's widthgetWorld()
Gets the current world this entity resides indouble
getX()
Gets the x-coordinate of this entitydouble
getY()
Gets the y-coordinate of this entityfloat
getYaw()
Gets this entity's yawdouble
getZ()
Gets the z-coordinate of this entityboolean
Checks whether the entity has a fixedPose
boolean
Returns whether gravity applies to this entity.boolean
Gets if this entity has no physics.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 if the entity currently has its freeze ticks locked to a set amount.boolean
isFrozen()
Gets if the entity is fully frozen (it has been in powdered snow for max freeze ticks).boolean
Gets whether the entity is glowing or not.boolean
Check if entity is in bubble columnboolean
isInLava()
Check if entity is in lavaboolean
Check if entity is inside powdered snow.boolean
isInRain()
Check if entity is in rainboolean
Returns whether this entity is inside a vehicle.boolean
Gets whether the entity is invisible or not.boolean
Gets whether the entity is invulnerable or not.boolean
Returns true if the entity is in water.boolean
Check if entity is in water or bubble columnboolean
Check if entity is in water or rainboolean
Check if entity is in water or rain or bubble columnboolean
Checks if this entity has been spawned in a world.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
Returns if the entity is in sneak modeboolean
Check if entity is inside a ticking chunkboolean
Check if entity is underwaterboolean
isValid()
Returns false if the entity has died, been despawned for some other reason, or has not been added to the world.boolean
Gets whether or not this entity is visible by default.boolean
Gets if the entity has visual fire (it will always appear to be on fire).boolean
Leave the current vehicle.void
lockFreezeTicks
(boolean locked) Sets if the entity currently has its freeze ticks locked, preventing default vanilla freeze tick modification.void
playEffect
(@NotNull EntityEffect type) Performs the specifiedEntityEffect
for this entity.void
remove()
Mark the entity's removal.boolean
removePassenger
(@NotNull Entity passenger) Remove a passenger from the vehicle.boolean
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
setFreezeTicks
(int ticks) Sets the entity's current freeze ticks (amount of ticks the entity has been in powdered snow).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
setInvisible
(boolean invisible) Sets whether the entity is invisible or not.void
setInvulnerable
(boolean flag) Sets whether the entity is invulnerable or not.void
Deprecated, for removal: This API element is subject to removal in a future version.method is for internal use only and will be removedvoid
setNoPhysics
(boolean noPhysics) Sets this entities no physics status.boolean
setPassenger
(@NotNull 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.default void
Sets the entity's currentPose
.void
Sets the entity's currentPose
.void
setRotation
(float yaw, float pitch) Sets the entity's rotation.void
setSilent
(boolean flag) Sets whether the entity is silent or not.void
setSneaking
(boolean sneak) Sets the sneak mode the entity.void
setTicksLived
(int value) Sets the amount of ticks this entity has lived for.void
setVelocity
(@NotNull Vector velocity) Sets this entity's velocity in meters per tickvoid
setVisibleByDefault
(boolean visible) Sets whether or not this entity is visible by default.void
setVisualFire
(boolean fire) Sets if the entity has visual fire (it will always appear to be on fire).default boolean
Spawns the entity in the world at the givenLocation
with the default spawn reason.boolean
spawnAt
(@NotNull Location location, CreatureSpawnEvent.SpawnReason reason) Spawns the entity in the world at the givenLocation
with the reason given.spigot()
Gets the entity's display name formatted with their team prefix/suffix and the entity's default hover/click events.boolean
Teleports this entity to the given location.default boolean
teleport
(@NotNull Location location, TeleportFlag @NotNull ... teleportFlags) Teleports this entity to the given location.boolean
teleport
(@NotNull Location location, @NotNull PlayerTeleportEvent.TeleportCause cause) Teleports this entity to the given location.boolean
teleport
(@NotNull Location location, @NotNull PlayerTeleportEvent.TeleportCause cause, TeleportFlag @NotNull ... teleportFlags) Teleports this entity to the given location.boolean
Teleports this entity to the target Entity.boolean
teleport
(@NotNull Entity destination, @NotNull PlayerTeleportEvent.TeleportCause cause) Teleports this entity to the target Entity.default @NotNull CompletableFuture
<Boolean> Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready.default @NotNull CompletableFuture
<Boolean> Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready.teleportAsync
(@NotNull Location loc, @NotNull PlayerTeleportEvent.TeleportCause cause, TeleportFlag @NotNull ... teleportFlags) Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready.boolean
wouldCollideUsing
(@NotNull BoundingBox boundingBox) This checks using the given boundingbox as the entity's boundingbox if the entity would collide with anything.Methods inherited from interface net.kyori.adventure.audience.Audience
clearResourcePacks, clearTitle, deleteMessage, deleteMessage, filterAudience, forEachAudience, hideBossBar, openBook, openBook, playSound, playSound, playSound, removeResourcePacks, removeResourcePacks, removeResourcePacks, removeResourcePacks, removeResourcePacks, resetTitle, sendActionBar, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendPlayerListHeaderAndFooter, sendResourcePacks, sendResourcePacks, sendResourcePacks, sendTitlePart, showBossBar, showTitle, stopSound, stopSound
Methods inherited from interface org.bukkit.command.CommandSender
getName, name, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlainMessage, sendRichMessage, sendRichMessage
Methods inherited from interface net.kyori.adventure.text.event.HoverEventSource
asHoverEvent
Methods inherited from interface org.bukkit.metadata.Metadatable
getMetadata, hasMetadata, removeMetadata, setMetadata
Methods inherited from interface org.bukkit.Nameable
customName, customName, getCustomName, setCustomName
Methods inherited from interface org.bukkit.permissions.Permissible
addAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, permissionValue, permissionValue, recalculatePermissions, removeAttachment
Methods inherited from interface org.bukkit.persistence.PersistentDataHolder
getPersistentDataContainer
Methods inherited from interface net.kyori.adventure.pointer.Pointered
get, getOrDefault, getOrDefaultFrom, pointers
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
@Contract("null -> null; !null -> !null") @Nullable @Nullable Location getLocation(@Nullable @Nullable Location loc) 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:
-
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
-
teleport
default boolean teleport(@NotNull @NotNull Location location, @NotNull TeleportFlag @NotNull ... teleportFlags) Teleports this entity to the given location.- Parameters:
location
- New location to teleport this entity toteleportFlags
- Flags to be used in this teleportation- Returns:
true
if the teleport was successful
-
teleport
boolean teleport(@NotNull @NotNull Location location, @NotNull @NotNull PlayerTeleportEvent.TeleportCause cause, @NotNull TeleportFlag @NotNull ... teleportFlags) Teleports this entity to the given location.- Parameters:
location
- New location to teleport this entity tocause
- The cause of this teleportationteleportFlags
- Flags to be used in this teleportation- 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 to- Returns:
true
if the teleport was successful
-
teleport
boolean teleport(@NotNull @NotNull Location location, @NotNull @NotNull PlayerTeleportEvent.TeleportCause cause) 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
boolean teleport(@NotNull @NotNull Entity destination, @NotNull @NotNull PlayerTeleportEvent.TeleportCause cause) 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
-
teleportAsync
Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready.- Parameters:
loc
- Location to teleport to- Returns:
- A future that will be completed with the result of the teleport
-
teleportAsync
default @NotNull CompletableFuture<Boolean> teleportAsync(@NotNull @NotNull Location loc, @NotNull @NotNull PlayerTeleportEvent.TeleportCause cause) Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready.- Parameters:
loc
- Location to teleport tocause
- Reason for teleport- Returns:
- A future that will be completed with the result of the teleport
-
teleportAsync
@NotNull CompletableFuture<Boolean> teleportAsync(@NotNull @NotNull Location loc, @NotNull @NotNull PlayerTeleportEvent.TeleportCause cause, @NotNull TeleportFlag @NotNull ... teleportFlags) Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready.- Parameters:
loc
- Location to teleport tocause
- Reason for teleportteleportFlags
- Flags to be used in this teleportation- Returns:
- A future that will be completed with the result of the teleport
-
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 the network protocol ID for this entity. This is not to be used as an identifier for the entity except in network-related operations. UsegetUniqueId()
as an entity identifier instead.- Returns:
- the network protocol ID
- See Also:
-
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
-
setVisualFire
void setVisualFire(boolean fire) Sets if the entity has visual fire (it will always appear to be on fire).- Parameters:
fire
- whether visual fire is enabled
-
isVisualFire
boolean isVisualFire()Gets if the entity has visual fire (it will always appear to be on fire).- Returns:
- whether visual fire is enabled
-
getFreezeTicks
int getFreezeTicks()Returns the entity's current freeze ticks (amount of ticks the entity has been in powdered snow).- Returns:
- int freeze ticks
-
getMaxFreezeTicks
int getMaxFreezeTicks()Returns the entity's maximum freeze ticks (amount of ticks before it will be fully frozen)- Returns:
- int max freeze ticks
-
setFreezeTicks
void setFreezeTicks(int ticks) Sets the entity's current freeze ticks (amount of ticks the entity has been in powdered snow).- Parameters:
ticks
- Current ticks
-
isFrozen
boolean isFrozen()Gets if the entity is fully frozen (it has been in powdered snow for max freeze ticks).- Returns:
- freeze status
-
setInvisible
void setInvisible(boolean invisible) Sets whether the entity is invisible or not.This setting is undefined for non-living entities like boats or paintings. Non-living entities that are marked as invisible through this method may e.g. only hide their shadow. To hide such entities from players completely, see
Player.hideEntity(org.bukkit.plugin.Plugin, Entity)
.- Parameters:
invisible
- If the entity is invisible
-
isInvisible
boolean isInvisible()Gets whether the entity is invisible or not.- Returns:
- Whether the entity is invisible
-
setNoPhysics
void setNoPhysics(boolean noPhysics) Sets this entities no physics status.- Parameters:
noPhysics
- boolean indicating if the entity should not have physics.
-
hasNoPhysics
boolean hasNoPhysics()Gets if this entity has no physics.- Returns:
- true if the entity does not have physics.
-
isFreezeTickingLocked
boolean isFreezeTickingLocked()Gets if the entity currently has its freeze ticks locked to a set amount.This is only set by plugins
- Returns:
- locked or not
-
lockFreezeTicks
void lockFreezeTicks(boolean locked) Sets if the entity currently has its freeze ticks locked, preventing default vanilla freeze tick modification.- Parameters:
locked
- prevent vanilla modification or not
-
remove
void remove()Mark the entity's removal.- Throws:
UnsupportedOperationException
- if you try to remove aPlayer
usePlayer.kickPlayer(String)
in this case instead
-
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, been despawned for some other reason, or has not been added to the world.- 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:
-
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
@Deprecated(since="1.20.4", forRemoval=true) void setLastDamageCause(@Nullable @Nullable EntityDamageEvent event) Deprecated, for removal: This API element is subject to removal in a future version.method is for internal use only and will be removedRecord 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.
-
getSwimSound
Get theSound
this entity makes while swimming.- Returns:
- the swimming sound
-
getSwimSplashSound
Get theSound
this entity makes when splashing in water. For most entities, this is justSound.ENTITY_GENERIC_SPLASH
.- Returns:
- the splash sound
-
getSwimHighSpeedSplashSound
Get theSound
this entity makes when splashing in water at high speeds. For most entities, this is justSound.ENTITY_GENERIC_SPLASH
.- Returns:
- the splash sound
-
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 entity 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
-
setVisibleByDefault
void setVisibleByDefault(boolean visible) Sets whether or not this entity is visible by default. If this entity is not visible by default, thenPlayer.showEntity(org.bukkit.plugin.Plugin, org.bukkit.entity.Entity)
will need to be called before the entity is visible to a given player.- Parameters:
visible
- default visibility status
-
isVisibleByDefault
boolean isVisibleByDefault()Gets whether or not this entity is visible by default. If this entity is not visible by default, thenPlayer.showEntity(org.bukkit.plugin.Plugin, org.bukkit.entity.Entity)
will need to be called before the entity is visible to a given player.- Returns:
- default visibility status
-
getTrackedBy
Get all players that are currently tracking this entity.'Tracking' means that this entity has been sent to the player and that they are receiving updates on its state. Note that the client's
'Entity Distance'
setting does not affect the range at which entities are tracked.- Returns:
- the players tracking this entity, or an empty set if none
-
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:
-
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
-
isSneaking
boolean isSneaking()Returns if the entity is in sneak mode- Returns:
- true if the entity is in sneak mode
-
setSneaking
void setSneaking(boolean sneak) Sets the sneak mode the entity.Note: For most Entities this does not update Entity's pose and just makes its name tag less visible.
- Parameters:
sneak
- true if the entity should be sneaking
-
setPose
Sets the entity's currentPose
.Note: While poses affect some things like hitboxes, they do not change the entity's state (e.g. having
Pose.SNEAKING
does not guaranteeisSneaking()
beingtrue
).If applied to the
Player
, they might see a different pose client-side.- Parameters:
pose
- a newPose
- See Also:
-
setPose
Sets the entity's currentPose
.Note: While poses affect some things like hitboxes, they do not change the entity's state (e.g. having
Pose.SNEAKING
does not guaranteeisSneaking()
beingtrue
).If applied to the
Player
, they might see a different pose client-side. -
hasFixedPose
boolean hasFixedPose()Checks whether the entity has a fixedPose
- Returns:
- whether the entity has a fixed
Pose
- See Also:
-
getSpawnCategory
Get the category of spawn to which this entity belongs.- Returns:
- the entity´s category spawn
-
isInWorld
boolean isInWorld()Checks if this entity has been spawned in a world.
Entities not spawned in a world will not tick, be sent to players, or be saved to the server files.- Returns:
- whether the entity has been spawned in a world
-
getAsString
Get this entity as an NBT string.This string should not be relied upon as a serializable value.
- Returns:
- the NBT string or null if one cannot be made
-
createSnapshot
Crates anEntitySnapshot
representing the current state of this entity.- Returns:
- a snapshot representing this entity or null if one cannot be made
-
copy
Creates a copy of this entity and all its data. Does not spawn the copy in the world.
Note: Players cannot be copied.- Returns:
- a copy of this entity.
-
copy
Creates a copy of this entity and all its data. Spawns the copy at the given location.
Note: Players cannot be copied.- Parameters:
to
- the location to copy to- Returns:
- a copy of this entity.
-
spigot
- Specified by:
spigot
in interfaceCommandSender
-
teamDisplayName
Gets the entity's display name formatted with their team prefix/suffix and the entity's default hover/click events.- Returns:
- the team display name
-
asHoverEvent
@NotNull default HoverEvent<HoverEvent.ShowEntity> asHoverEvent(@NotNull UnaryOperator<HoverEvent.ShowEntity> op) Description copied from interface:net.kyori.adventure.text.event.HoverEventSource
Creates a hover event with value derived from this object.The event value will be passed through the provided callback to allow transforming the original value of the event.
- Specified by:
asHoverEvent
in interfaceHoverEventSource<HoverEvent.ShowEntity>
- Parameters:
op
- transformation on value- Returns:
- a hover event
-
getOrigin
Gets the location where this entity originates from.This value can be null if the entity hasn't yet been added to the world.
- Returns:
- Location where entity originates or null if not yet added
-
fromMobSpawner
boolean fromMobSpawner()Returns whether this entity was spawned from a mob spawner.- Returns:
- True if entity spawned from a mob spawner
-
getChunk
Gets the latest chunk an entity is currently or was in.- Returns:
- The current, or most recent chunk if the entity is invalid (which may load the chunk)
-
getEntitySpawnReason
- Returns:
- The
CreatureSpawnEvent.SpawnReason
that initially spawned this entity.
-
isUnderWater
boolean isUnderWater()Check if entity is underwater -
isInRain
boolean isInRain()Check if entity is in rain -
isInBubbleColumn
boolean isInBubbleColumn()Check if entity is in bubble column -
isInWaterOrRain
boolean isInWaterOrRain()Check if entity is in water or rain -
isInWaterOrBubbleColumn
boolean isInWaterOrBubbleColumn()Check if entity is in water or bubble column -
isInWaterOrRainOrBubbleColumn
boolean isInWaterOrRainOrBubbleColumn()Check if entity is in water or rain or bubble column -
isInLava
boolean isInLava()Check if entity is in lava -
isTicking
boolean isTicking()Check if entity is inside a ticking chunk -
getTrackedPlayers
Deprecated.slightly misleading name, usegetTrackedBy()
Returns a set ofPlayers
within this entity's tracking range (players that can "see" this entity).- Returns:
- players in tracking range
-
spawnAt
Spawns the entity in the world at the givenLocation
with the default spawn reason.This will not spawn the entity if the entity is already spawned or has previously been despawned.
Also, this method will fire the same events as a normal entity spawn.
- Parameters:
location
- The location to spawn the entity at.- Returns:
- Whether the entity was successfully spawned.
-
spawnAt
boolean spawnAt(@NotNull @NotNull Location location, @NotNull CreatureSpawnEvent.SpawnReason reason) Spawns the entity in the world at the givenLocation
with the reason given.This will not spawn the entity if the entity is already spawned or has previously been despawned.
Also, this method will fire the same events as a normal entity spawn.
- Parameters:
location
- The location to spawn the entity at.reason
- The reason for the entity being spawned.- Returns:
- Whether the entity was successfully spawned.
-
isInPowderedSnow
boolean isInPowderedSnow()Check if entity is inside powdered snow.- Returns:
- true if in powdered snow.
-
getX
double getX()Gets the x-coordinate of this entity- Returns:
- x-coordinate
-
getY
double getY()Gets the y-coordinate of this entity- Returns:
- y-coordinate
-
getZ
double getZ()Gets the z-coordinate of this entity- Returns:
- z-coordinate
-
getPitch
float getPitch()Gets this entity's pitch- Returns:
- the entity's pitch
- See Also:
-
getYaw
float getYaw()Gets this entity's yaw- Returns:
- the entity's yaw
- See Also:
-
collidesAt
Checks for any collisions with the entity's bounding box at the provided location. This will check for any colliding entities (boats, shulkers) / worldborder / blocks. Does not load chunks that are within the bounding box at the specified location.- Parameters:
location
- the location to check collisions in- Returns:
- collides or not
-
wouldCollideUsing
This checks using the given boundingbox as the entity's boundingbox if the entity would collide with anything. This will check for any colliding entities (boats, shulkers) / worldborder / blocks. Does not load chunks that are within the bounding box.- Parameters:
boundingBox
- the box to check collisions in- Returns:
- collides or not
-
getScheduler
Returns the task scheduler for this entity. The entity scheduler can be used to schedule tasks that are guaranteed to always execute on the tick thread that owns the entity.If you do not need/want to make your plugin run on Folia, use
Server.getScheduler()
instead.- Returns:
- the task scheduler for this entity.
- See Also:
-
getScoreboardEntryName
Gets the string name of the entity used to track it inScoreboards
.- Returns:
- the scoreboard entry name
- See Also:
-
broadcastHurtAnimation
Broadcasts a hurt animation. This fakes incoming damage towards the target entity.The target players cannot include
this
player. For self-damage, usePlayer.sendHurtAnimation(float)
.- Parameters:
players
- the players to broadcast to (cannot includethis
- Throws:
IllegalArgumentException
- ifthis
is contained inplayers
-
getPassengers()