Package org.spongepowered.api.entity
Interface Entity
-
- All Superinterfaces:
CopyableDataHolder
,DataHolder
,DataHolder.Mutable
,DataSerializable
,EntityProjectileSource
,HoverEventSource<HoverEvent.ShowEntity>
,Identifiable
,Locatable
,ProjectileSource
,RandomProvider
,SerializableDataHolder
,SerializableDataHolder.Mutable
,Sound.Emitter
,ValueContainer
- All Known Subinterfaces:
Aerial
,Ageable
,Agent
,Ambient
,Animal
,Aquatic
,AreaEffectCloud
,ArmorStand
,Arrow
,ArrowEntity
,Bat
,Bee
,Blaze
,BlockOccupiedMinecart
,Boat
,Boss
,CarrierMinecart<M>
,Cat
,CaveSpider
,ChestMinecart
,Chicken
,ClientPlayer
,Cod
,CommandBlockMinecart
,ComplexLiving<T>
,ComplexLivingPart<P>
,Cow
,Creature
,Creeper
,DamagingProjectile
,Dolphin
,Donkey
,DragonFireball
,Drowned
,Egg
,ElderGuardian
,EndCrystal
,EnderDragon
,EnderDragonPart
,Enderman
,Endermite
,EnderPearl
,EntityTargetingProjectile
,Evoker
,EvokerFangs
,ExperienceBottle
,ExperienceOrb
,Explosive
,ExplosiveFireball
,EyeOfEnder
,FallingBlock
,FireballEntity
,FireworkRocket
,Fish
,FishingBobber
,Fox
,FurnaceMinecart
,FusedExplosive
,Ghast
,Giant
,Golem
,Guardian
,Hanging
,Hoglin
,HopperMinecart
,Horse
,HorseLike
,Hostile
,Human
,Humanoid
,Husk
,Illager
,Illusioner
,IronGolem
,Item
,ItemFrame
,LeashKnot
,LightningBolt
,Living
,Llama
,LlamaLike
,LlamaSpit
,LocalPlayer
,MagmaCube
,Minecart
,MinecartLike
,Monster
,Mooshroom
,Mule
,Ocelot
,PackHorse
,Painting
,Panda
,Parrot
,Patroller
,Phantom
,Pig
,Piglin
,PiglinBrute
,PiglinLike
,Pillager
,Player
,PolarBear
,Potion
,PrimedTNT
,Projectile
,Pufferfish
,Rabbit
,Raider
,Ranger
,Ravager
,RemotePlayer
,Salmon
,SchoolingFish
,ServerPlayer
,Sheep
,Shulker
,ShulkerBullet
,Silverfish
,Sittable
,Skeleton
,SkeletonHorse
,SkeletonLike
,Slime
,SmallFireball
,Snowball
,SnowGolem
,SpawnerMinecart
,SpectralArrow
,Spellcaster
,Spider
,Squid
,Stray
,Strider
,TameableAnimal
,TameableHorse
,TNTMinecart
,Trader
,TraderLlama
,Trident
,TropicalFish
,Turtle
,Vehicle
,Vex
,Villager
,Vindicator
,WanderingTrader
,WeatherEffect
,Witch
,Wither
,WitherSkeleton
,WitherSkull
,Wolf
,Zoglin
,Zombie
,ZombieHorse
,ZombieLike
,ZombieVillager
,ZombifiedPiglin
@DoNotStore public interface Entity extends Identifiable, HoverEventSource<HoverEvent.ShowEntity>, Locatable, EntityProjectileSource, Sound.Emitter, SerializableDataHolder.Mutable, RandomProvider
An entity is a Minecraft entity.Examples of entities include:
- Zombies
- Sheep
- Players
- Dropped items
- Dropped experience points
- etc.
Blocks and items (when they are in inventories) are not entities.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolder
DataHolder.Immutable<I extends DataHolder.Immutable<I>>, DataHolder.Mutable
-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.SerializableDataHolder
SerializableDataHolder.Immutable<I extends SerializableDataHolder.Immutable<I>>, SerializableDataHolder.Mutable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default Value.Mutable<Integer>
age()
HoverEvent<HoverEvent.ShowEntity>
asHoverEvent(UnaryOperator<HoverEvent.ShowEntity> op)
default Value<Double>
baseSize()
default Optional<Value<Entity>>
baseVehicle()
Optional<AABB>
boundingBox()
Gets the entity's bounding box, usually for collisions and interaction.default boolean
canSee(Entity entity)
Returns whether this entity can see the providedEntity
.Entity
copy()
Creates a clone copy of thisCopyableDataHolder
as a newCopyableDataHolder
such that all theValue
s are safely duplicated to the new instance.EntityArchetype
createArchetype()
Creates anEntityArchetype
for use withSchematic
s.EntitySnapshot
createSnapshot()
Creates anEntitySnapshot
.default Optional<Value.Mutable<UUID>>
creator()
default Optional<Value.Mutable<Component>>
customName()
default Value.Mutable<Boolean>
customNameVisible()
default boolean
damage(double damage, Supplier<? extends DamageSource> damageSource)
Damages thisEntity
with the givenDamageSource
.boolean
damage(double damage, DamageSource damageSource)
Damages thisEntity
with the givenDamageSource
.default Vector3d
direction()
Gets the unit vector representing the direction of this entity.default Value.Mutable<Component>
displayName()
default Value<Double>
eyeHeight()
default Value<Vector3d>
eyePosition()
default Value.Mutable<Double>
fallDistance()
default Value.Mutable<Ticks>
fireImmuneTicks()
default Optional<Value.Mutable<Ticks>>
fireTicks()
default Value.Mutable<Boolean>
glowing()
default Value.Mutable<Boolean>
gravityAffected()
default Value<Double>
height()
default Value.Mutable<Boolean>
invisible()
default Value.Mutable<Ticks>
invulnerabilityTicks()
default Value.Mutable<Boolean>
invulnerable()
boolean
isLoaded()
Returns whether this entity is still loaded in a world/chunk.boolean
isRemoved()
Returns whether this entity has been removed.default Value.Mutable<Boolean>
isTransient()
void
lookAt(Vector3d targetPos)
Makes the entity look at the specified target position.default Value.Mutable<Integer>
maxAir()
default Collection<? extends Entity>
nearbyEntities(double distance)
Gets the nearby entities within the desired distance.default Collection<? extends Entity>
nearbyEntities(double distance, Predicate<? super Entity> predicate)
Gets the nearby entities that satisfy the desired predicate.default Optional<Value.Mutable<UUID>>
notifier()
default Value<Boolean>
onGround()
default ListValue.Mutable<Entity>
passengers()
Vector3d
position()
Gets the position of this entitydefault Value.Mutable<Integer>
remainingAir()
void
remove()
Mark this entity for removal in the very near future, preferably within one game tick.Vector3d
rotation()
Gets the rotation.Vector3d
scale()
Gets the scale.default SetValue.Mutable<String>
scoreboardTags()
boolean
setLocation(ServerLocation location)
Sets the location of this entity.boolean
setLocationAndRotation(ServerLocation location, Vector3d rotation)
Moves the entity to the specified location and sets the rotation.boolean
setLocationAndRotation(ServerLocation location, Vector3d rotation, EnumSet<RelativePositions> relativePositions)
Moves the entity to the specified location and sets the rotation.boolean
setPosition(Vector3d position)
Sets the position of this entity.void
setRotation(Vector3d rotation)
Sets the rotation of this entity.void
setScale(Vector3d scale)
Sets the scale.boolean
setTransform(Transform transform)
Sets theTransform
.default Value.Mutable<Boolean>
silent()
default Value.Mutable<Boolean>
sneaking()
default Value.Mutable<Boolean>
sprinting()
default Optional<Value.Mutable<Double>>
swiftness()
default boolean
transferToWorld(ServerWorld world)
Sets theServerLocation
of this entity to theServerWorld
's spawn point.boolean
transferToWorld(ServerWorld world, Vector3d position)
Sets theServerLocation
of this entity to a new position in a world.Transform
transform()
Gets theTransform
.EntityType<?>
type()
Gets theEntityType
.default Value.Mutable<Boolean>
vanish()
Deprecated.UseVanishState
insteaddefault Value.Mutable<Boolean>
vanishIgnoresCollision()
Deprecated.UsevanishState()
insteaddefault Value.Mutable<Boolean>
vanishPreventsTargeting()
Deprecated.UsevanishState()
insteaddefault Value.Mutable<VanishState>
vanishState()
default Optional<Value.Mutable<Entity>>
vehicle()
default Value.Mutable<Vector3d>
velocity()
default Value<Boolean>
wet()
-
Methods inherited from interface org.spongepowered.api.data.DataHolder.Mutable
copyFrom, copyFrom, offer, offer, offer, offer, offerAll, offerAll, offerAll, offerAll, offerAll, offerAll, offerSingle, offerSingle, offerSingle, offerSingle, remove, remove, remove, removeAll, removeAll, removeAll, removeAll, removeAll, removeAll, removeKey, removeKey, removeSingle, removeSingle, transform, transform, tryOffer, tryOffer, tryOffer, undo
-
Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
-
Methods inherited from interface net.kyori.adventure.text.event.HoverEventSource
asHoverEvent
-
Methods inherited from interface org.spongepowered.api.util.Identifiable
uniqueId
-
Methods inherited from interface org.spongepowered.api.world.Locatable
blockPosition, location, serverLocation, world
-
Methods inherited from interface org.spongepowered.api.projectile.source.ProjectileSource
launchProjectile, launchProjectile, launchProjectile, launchProjectile, launchProjectileTo, launchProjectileTo
-
Methods inherited from interface org.spongepowered.api.util.RandomProvider
random
-
Methods inherited from interface org.spongepowered.api.data.SerializableDataHolder
validateRawData
-
Methods inherited from interface org.spongepowered.api.data.SerializableDataHolder.Mutable
setRawData
-
-
-
-
Method Detail
-
type
EntityType<?> type()
Gets theEntityType
.- Returns:
- The type
-
createSnapshot
EntitySnapshot createSnapshot()
Creates anEntitySnapshot
.- Returns:
- The snapshot
-
copy
Entity copy()
Description copied from interface:CopyableDataHolder
Creates a clone copy of thisCopyableDataHolder
as a newCopyableDataHolder
such that all theValue
s are safely duplicated to the new instance. It is not guaranteed that the returning container is of the same type as this container.- Specified by:
copy
in interfaceCopyableDataHolder
- Specified by:
copy
in interfaceSerializableDataHolder
- Specified by:
copy
in interfaceSerializableDataHolder.Mutable
- Returns:
- The new copy
-
createArchetype
EntityArchetype createArchetype()
Creates anEntityArchetype
for use withSchematic
s.- Returns:
- The archetype
-
position
Vector3d position()
Gets the position of this entity- Returns:
- The position of this entity
-
setPosition
boolean setPosition(Vector3d position)
Sets the position of this entity.- Parameters:
position
- The position to set- Returns:
- True if set, false if not
-
setLocation
boolean setLocation(ServerLocation location)
Sets the location of this entity.- Parameters:
location
- The location to set- Returns:
- True if location was set successfully, false otherwise
-
rotation
Vector3d rotation()
Gets the rotation.The format of the rotation is represented by:
x -> pitch
,y -> yaw
,z -> roll
- Returns:
- The rotation
-
setRotation
void setRotation(Vector3d rotation)
Sets the rotation of this entity.The format of the rotation is represented by:
x -> pitch
,y -> yaw
,z -> roll
- Parameters:
rotation
- The rotation to set the entity to
-
direction
default Vector3d direction()
Gets the unit vector representing the direction of this entity.- Returns:
- The direction
-
setLocationAndRotation
boolean setLocationAndRotation(ServerLocation location, Vector3d rotation)
Moves the entity to the specified location and sets the rotation.The format of the rotation is represented by:
x -> pitch
,y -> yaw
,z -> roll
- Parameters:
location
- The location to setrotation
- The rotation to set- Returns:
- True if location was set successfully, false otherwise
-
setLocationAndRotation
boolean setLocationAndRotation(ServerLocation location, Vector3d rotation, EnumSet<RelativePositions> relativePositions)
Moves the entity to the specified location and sets the rotation.RelativePositions
listed inside the EnumSet are considered relative.The format of the rotation is represented by:
x -> pitch
,y -> yaw
,z -> roll
- Parameters:
location
- The location to setrotation
- The rotation to setrelativePositions
- The coordinates to set relatively- Returns:
- True if location was set successfully, false otherwise
-
scale
Vector3d scale()
Gets the scale.- Returns:
- The entity scale
-
setScale
void setScale(Vector3d scale)
Sets the scale.- Parameters:
scale
- The scale
-
setTransform
boolean setTransform(Transform transform)
Sets theTransform
.- Parameters:
transform
- The transform to set- Returns:
- True if the transform was set successfully, false if the transform couldn't be set
-
transferToWorld
default boolean transferToWorld(ServerWorld world)
Sets theServerLocation
of this entity to theServerWorld
's spawn point.- Parameters:
world
- The world to transfer to- Returns:
- Whether the transfer was successful, returns false if the action is cancelled or not possible (eg. because the entity has been removed)
-
transferToWorld
boolean transferToWorld(ServerWorld world, Vector3d position)
Sets theServerLocation
of this entity to a new position in a world.- Parameters:
world
- The world to transfer toposition
- The position in the target world- Returns:
- Whether the transfer was successful, returns false if the action is cancelled or not possible (eg. because the entity has been removed)
-
boundingBox
Optional<AABB> boundingBox()
Gets the entity's bounding box, usually for collisions and interaction. The box has an offset matching the entity's positions. That is to say, it is absolutely positioned and not relative to the entity.- Returns:
- The axis aligned bounding box
-
isRemoved
boolean isRemoved()
Returns whether this entity has been removed.- Returns:
- True if this entity has been removed
-
isLoaded
boolean isLoaded()
Returns whether this entity is still loaded in a world/chunk.- Returns:
- True if this entity is still loaded
-
remove
void remove()
Mark this entity for removal in the very near future, preferably within one game tick.
-
damage
default boolean damage(double damage, Supplier<? extends DamageSource> damageSource)
Damages thisEntity
with the givenDamageSource
.- Parameters:
damage
- The damage to dealdamageSource
- The cause of the damage- Returns:
- True if damaging the entity was successful
-
damage
boolean damage(double damage, DamageSource damageSource)
Damages thisEntity
with the givenDamageSource
.- Parameters:
damage
- The damage to dealdamageSource
- The cause of the damage- Returns:
- True if damaging the entity was successful
-
nearbyEntities
default Collection<? extends Entity> nearbyEntities(double distance)
Gets the nearby entities within the desired distance.- Parameters:
distance
- The distance- Returns:
- The collection of nearby entities
- See Also:
EntityVolume.nearbyEntities(Vector3d, double)
-
nearbyEntities
default Collection<? extends Entity> nearbyEntities(double distance, Predicate<? super Entity> predicate)
Gets the nearby entities that satisfy the desired predicate.- Parameters:
distance
- The distancepredicate
- The predicate to use- Returns:
- The collection of entities
- See Also:
EntityVolume.entities(AABB, Predicate)
-
canSee
default boolean canSee(Entity entity)
Returns whether this entity can see the providedEntity
.- Parameters:
entity
- The entity to check visibility for- Returns:
true
if this entity can see the provided entity
-
lookAt
void lookAt(Vector3d targetPos)
Makes the entity look at the specified target position.- Parameters:
targetPos
- Position to target
-
displayName
default Value.Mutable<Component> displayName()
- Returns:
- The display name of this entity
-
fallDistance
default Value.Mutable<Double> fallDistance()
- Returns:
- The fall distance
-
passengers
default ListValue.Mutable<Entity> passengers()
- Returns:
- The list of passengers that may be riding this entity
-
vehicle
default Optional<Value.Mutable<Entity>> vehicle()
- Returns:
- The vehicle this entity may be riding
-
baseVehicle
default Optional<Value<Entity>> baseVehicle()
- Returns:
- The "base vehicle" of the entity vehicle riding chain
-
velocity
default Value.Mutable<Vector3d> velocity()
- Returns:
- The velocity of this entity
-
gravityAffected
default Value.Mutable<Boolean> gravityAffected()
- Returns:
- Whether this entity is affected by gravity
-
silent
default Value.Mutable<Boolean> silent()
- Returns:
- Whether this entity is silent
-
creator
default Optional<Value.Mutable<UUID>> creator()
- Returns:
- The unique id of the creator of this entity
-
notifier
default Optional<Value.Mutable<UUID>> notifier()
- Returns:
- The unique id of the notifier of this entity
-
fireTicks
default Optional<Value.Mutable<Ticks>> fireTicks()
- Returns:
- The amount of time in ticks the entity is will continue burn for
-
fireImmuneTicks
default Value.Mutable<Ticks> fireImmuneTicks()
- Returns:
- The amount of time to delay in ticks before the entity will be burned by fire
-
isTransient
default Value.Mutable<Boolean> isTransient()
- Returns:
- The transient state
-
age
default Value.Mutable<Integer> age()
- Returns:
- The age of this entity
-
invulnerabilityTicks
default Value.Mutable<Ticks> invulnerabilityTicks()
- Returns:
- The amount of ticks the entity will remain invulnerable for
-
customNameVisible
default Value.Mutable<Boolean> customNameVisible()
- Returns:
- Whether a custom name is visible on the entity
-
glowing
default Value.Mutable<Boolean> glowing()
- Returns:
- Whether the entity has a glowing outline
-
invisible
default Value.Mutable<Boolean> invisible()
- Returns:
- Whether the entity is currently invisible
-
invulnerable
default Value.Mutable<Boolean> invulnerable()
- Returns:
- Whether the entity is invulnerable
-
sneaking
default Value.Mutable<Boolean> sneaking()
- Returns:
- Whether the entity is sneaking
-
sprinting
default Value.Mutable<Boolean> sprinting()
- Returns:
- Whether the entity is sprinting
-
maxAir
default Value.Mutable<Integer> maxAir()
- Returns:
- The max air supply
-
remainingAir
default Value.Mutable<Integer> remainingAir()
- Returns:
- The remaining air supply
-
scoreboardTags
default SetValue.Mutable<String> scoreboardTags()
- Returns:
- The scoreboard tags applied to the entity
-
vanishState
default Value.Mutable<VanishState> vanishState()
- Returns:
- The current vanish state of the entity
-
vanish
@Deprecated default Value.Mutable<Boolean> vanish()
Deprecated.UseVanishState
instead- Returns:
- Whether the entity is vanished
-
vanishIgnoresCollision
@Deprecated default Value.Mutable<Boolean> vanishIgnoresCollision()
Deprecated.UsevanishState()
instead- Returns:
- Whether the entity ignores collision with other entities
-
vanishPreventsTargeting
@Deprecated default Value.Mutable<Boolean> vanishPreventsTargeting()
Deprecated.UsevanishState()
instead- Returns:
- Whether the entity can be targeted for attack by another entity
-
customName
default Optional<Value.Mutable<Component>> customName()
- Returns:
- The custom name of the entity
-
swiftness
default Optional<Value.Mutable<Double>> swiftness()
- Returns:
- The current swiftness of the entity
-
asHoverEvent
HoverEvent<HoverEvent.ShowEntity> asHoverEvent(UnaryOperator<HoverEvent.ShowEntity> op)
- Specified by:
asHoverEvent
in interfaceHoverEventSource<HoverEvent.ShowEntity>
-
-