public interface Entity extends Identifiable, Locatable, DataHolder, Translatable
Examples of entities include:
Blocks and items (when they are in inventories) are not entities.
Modifier and Type | Method and Description |
---|---|
boolean |
addPassenger(Entity entity)
Sets the passenger entity (the entity that rides this one).
|
default boolean |
canSee(Entity entity)
Returns whether this entity can see the provided
Entity . |
void |
clearPassengers()
Removes all currently riding passengers from this entity.
|
EntityArchetype |
createArchetype()
Creates a new
EntityArchetype for use with Schematic s and
placing the archetype in multiple locations. |
EntitySnapshot |
createSnapshot()
Creates a
EntitySnapshot containing the EntityType and
data of this entity. |
boolean |
damage(double damage,
DamageSource damageSource)
Damages this
Entity with the given DamageSource . |
Entity |
getBaseVehicle()
Gets the entity vehicle that is the base of what ever stack the current
entity is a part of.
|
Optional<AABB> |
getBoundingBox()
Gets the entity's bounding box, usually for collisions and interaction.
|
Optional<UUID> |
getCreator()
|
default Collection<Entity> |
getNearbyEntities(double distance)
Gets the nearby entities within the desired distance.
|
default Collection<Entity> |
getNearbyEntities(Predicate<Entity> predicate)
Gets the nearby entities that satisfy the desired predicate.
|
Optional<UUID> |
getNotifier()
|
List<Entity> |
getPassengers()
Gets the entity passenger that rides this entity, if available.
|
Random |
getRandom()
Gets the Random Number Generator (RNG) for this entity.
|
com.flowpowered.math.vector.Vector3d |
getRotation()
Gets the rotation.
|
com.flowpowered.math.vector.Vector3d |
getScale()
Gets the entity scale.
|
Transform<World> |
getTransform()
Returns the entity transform as a new copy.
|
EntityType |
getType()
Gets the type of entity.
|
Optional<Entity> |
getVehicle()
Gets the entity vehicle that this entity is riding, if available.
|
default com.flowpowered.math.vector.Vector3d |
getVelocity()
Gets the
Vector3d representation of this entity's current
velocity. |
default Value<Boolean> |
gravity()
Returns whether this entity has gravity.
|
boolean |
hasPassenger(Entity entity)
Checks if the given entity is a passenger.
|
boolean |
isLoaded()
Returns whether this entity is still loaded in a world/chunk.
|
boolean |
isOnGround()
Returns whether this entity is on the ground (not in the air) or not.
|
boolean |
isRemoved()
Returns whether this entity has been removed.
|
void |
remove()
Mark this entity for removal in the very near future, preferably
within one game tick.
|
void |
removePassenger(Entity entity)
Removes the given entity as a passenger.
|
void |
setCreator(UUID uuid)
|
boolean |
setLocation(Location<World> location)
Sets the location of this entity.
|
boolean |
setLocationAndRotation(Location<World> location,
com.flowpowered.math.vector.Vector3d rotation)
Moves the entity to the specified location, and sets the rotation.
|
boolean |
setLocationAndRotation(Location<World> location,
com.flowpowered.math.vector.Vector3d rotation,
EnumSet<RelativePositions> relativePositions)
Moves the entity to the specified location, and sets the rotation.
|
default boolean |
setLocationAndRotationSafely(Location<World> location,
com.flowpowered.math.vector.Vector3d rotation)
Sets the location using a safe one from
TeleportHelper.getSafeLocation(Location) and the rotation of this
entity. |
default boolean |
setLocationAndRotationSafely(Location<World> location,
com.flowpowered.math.vector.Vector3d rotation,
EnumSet<RelativePositions> relativePositions)
Sets the location using a safe one from
TeleportHelper.getSafeLocation(Location) and the rotation of this
entity. |
default boolean |
setLocationSafely(Location<World> location)
Sets the location of this entity using a safe one from
TeleportHelper.getSafeLocation(Location) . |
void |
setNotifier(UUID uuid)
|
void |
setRotation(com.flowpowered.math.vector.Vector3d rotation)
Sets the rotation of this entity.
|
void |
setScale(com.flowpowered.math.vector.Vector3d scale)
Sets the entity scale.
|
boolean |
setTransform(Transform<World> transform)
Sets the entity transform.
|
default boolean |
setTransformSafely(Transform<World> transform)
Sets the transformation of this entity using a safe location from
TeleportHelper.getSafeLocation(Location) . |
boolean |
setVehicle(Entity entity)
Sets the vehicle entity (the entity that is ridden by this one).
|
default DataTransactionResult |
setVelocity(com.flowpowered.math.vector.Vector3d vector3d)
Sets the velocity for this entity.
|
default boolean |
transferToWorld(String worldName,
com.flowpowered.math.vector.Vector3d position)
Sets the location of this entity to a new position in a world which does
not have to be loaded (but must at least be enabled).
|
default boolean |
transferToWorld(UUID uuid,
com.flowpowered.math.vector.Vector3d position)
Sets the location of this entity to a new position in a world which does
not have to be loaded (but must at least be enabled).
|
default boolean |
transferToWorld(World world)
|
boolean |
transferToWorld(World world,
com.flowpowered.math.vector.Vector3d position)
Sets the
Location of this entity to a new position in a world. |
getUniqueId
getLocation, getWorld
setRawData, validateRawData
getContentVersion, toContainer
getApplicableProperties, getProperty
copyFrom, copyFrom, get, getContainers, getOrCreate, offer, offer, offer, offer, offer, offer, remove, remove, remove, require, supports, transform, tryOffer, tryOffer, tryOffer, tryOffer, undo
copy, get, getKeys, getOrElse, getOrNull, getValue, getValues, require, supports, supports
getTranslation
EntityType getType()
EntitySnapshot createSnapshot()
EntitySnapshot
containing the EntityType
and
data of this entity.Random getRandom()
boolean setLocation(Location<World> location)
location
- The location to setMoveEntityEvent.Teleport
being cancelled.default boolean setLocationSafely(Location<World> location)
TeleportHelper.getSafeLocation(Location)
. This is equivalent to a
teleport and also moves this entity's passengers.location
- The location to setMoveEntityEvent.Teleport
was cancelled.com.flowpowered.math.vector.Vector3d getRotation()
The format of the rotation is represented by:
x -> pitch
, y -> yaw
, z -> roll
void setRotation(com.flowpowered.math.vector.Vector3d rotation)
The format of the rotation is represented by:
x -> pitch
, y -> yaw
, z -> roll
rotation
- The rotation to set the entity toboolean setLocationAndRotation(Location<World> location, com.flowpowered.math.vector.Vector3d rotation)
The format of the rotation is represented by:
x -> pitch
, y -> yaw
, z -> roll
location
- The location to setrotation
- The rotation to setMoveEntityEvent.Teleport
being cancelledboolean setLocationAndRotation(Location<World> location, com.flowpowered.math.vector.Vector3d rotation, EnumSet<RelativePositions> relativePositions)
RelativePositions
listed inside the EnumSet are considered
relative.
The format of the rotation is represented by:
x -> pitch
, y -> yaw
, z -> roll
location
- The location to setrotation
- The rotation to setrelativePositions
- The coordinates to set relativelyMoveEntityEvent.Teleport
being cancelleddefault boolean setLocationAndRotationSafely(Location<World> location, com.flowpowered.math.vector.Vector3d rotation)
TeleportHelper.getSafeLocation(Location)
and the rotation of this
entity.
The format of the rotation is represented by:
x -> pitch
, y -> yaw
, z -> roll
location
- The location to setrotation
- The rotation to setMoveEntityEvent.Teleport
was cancelleddefault boolean setLocationAndRotationSafely(Location<World> location, com.flowpowered.math.vector.Vector3d rotation, EnumSet<RelativePositions> relativePositions)
TeleportHelper.getSafeLocation(Location)
and the rotation of this
entity. RelativePositions
listed inside the EnumSet are
considered relative.
The format of the rotation is represented by:
x -> pitch
, y -> yaw
, z -> roll
location
- The location to setrotation
- The rotation to setrelativePositions
- The coordinates to set relativelyMoveEntityEvent.Teleport
was cancelledcom.flowpowered.math.vector.Vector3d getScale()
Vector3d.ONE
.void setScale(com.flowpowered.math.vector.Vector3d scale)
scale
- The scaleTransform<World> getTransform()
boolean setTransform(Transform<World> transform)
transform
- The transform to setMoveEntityEvent.Teleport
being cancelled.default boolean setTransformSafely(Transform<World> transform)
TeleportHelper.getSafeLocation(Location)
.transform
- The transform to setMoveEntityEvent.Teleport
was cancelleddefault boolean transferToWorld(World world)
Location
of this entity to the World
's spawn
point.
This is equivalent to setting the location via
TargetedLocationData
.
world
- The world to transfer toboolean transferToWorld(World world, com.flowpowered.math.vector.Vector3d position)
Location
of this entity to a new position in a world.
This is equivalent to setting the location via
TargetedLocationData
.
world
- The world to transfer toposition
- The position in the target worlddefault boolean transferToWorld(String worldName, com.flowpowered.math.vector.Vector3d position)
If the target world is loaded then this is equivalent to
setting the location via TargetedLocationData
.
If the target world is unloaded but is enabled according to its
WorldArchetype.isEnabled()
then this will first load the world
before transferring the entity to that world.
If the target world is unloaded and not enabled then the transfer will fail.
worldName
- The name of the world to transfer toposition
- The position in the target worlddefault boolean transferToWorld(UUID uuid, com.flowpowered.math.vector.Vector3d position)
If the target world is loaded then this is equivalent to setting the
location via TargetedLocationData
.
If the target world is unloaded but is enabled according to its
WorldArchetype.isEnabled()
then this will first load the world
before transferring the entity to that world.
If the target world is unloaded and not enabled then the transfer will fail.
uuid
- The UUID of the target world to transfer toposition
- The position in the target worldOptional<AABB> getBoundingBox()
List<Entity> getPassengers()
boolean hasPassenger(Entity entity)
entity
- The entity passengerboolean addPassenger(Entity entity)
entity
- The entity passenger, or null to ejectvoid removePassenger(Entity entity)
entity
- The entity to remove as passengervoid clearPassengers()
Optional<Entity> getVehicle()
boolean setVehicle(@Nullable Entity entity)
entity
- The entity vehicle, or null to dismountEntity getBaseVehicle()
The returned entity can never ride another entity, that would make the ridden entity the base of the stack.
default com.flowpowered.math.vector.Vector3d getVelocity()
Vector3d
representation of this entity's current
velocity.default DataTransactionResult setVelocity(com.flowpowered.math.vector.Vector3d vector3d)
vector3d
- The vector 3d velocityboolean isOnGround()
boolean isRemoved()
boolean isLoaded()
void remove()
boolean damage(double damage, DamageSource damageSource)
Entity
with the given DamageSource
.damage
- The damage to dealdamageSource
- The cause of the damagedefault Collection<Entity> getNearbyEntities(double distance)
distance
- The distanceEntityUniverse.getNearbyEntities(Vector3d, double)
default Collection<Entity> getNearbyEntities(Predicate<Entity> predicate)
predicate
- The predicate to useEntityUniverse.getEntities(Predicate)
default boolean canSee(Entity entity)
Entity
.entity
- The entity to check visibility fortrue
if this entity can see the provided entityEntityArchetype createArchetype()
EntityArchetype
for use with Schematic
s and
placing the archetype in multiple locations.