public interface Entity extends Identifiable, DataHolder, DataSerializable
Examples of entities include:
Blocks and items (when they are in inventories) are not entities.
Modifier and Type | Method and Description |
---|---|
EntitySnapshot |
createSnapshot()
Creates a
EntitySnapshot containing the EntityType and data of this entity. |
boolean |
damage(double damage,
Cause cause)
|
Location<World> |
getLocation()
Get the location of 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()
Get the type of entity.
|
World |
getWorld()
Gets the current world this entity resides in.
|
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 |
setLocation(Location<World> location)
Sets the location of this entity.
|
void |
setLocationAndRotation(Location<World> location,
com.flowpowered.math.vector.Vector3d rotation)
Moves the entity to the specified location, and sets the rotation.
|
void |
setLocationAndRotation(Location<World> location,
com.flowpowered.math.vector.Vector3d rotation,
EnumSet<RelativePositions> relativePositions)
Moves the entity to the specified location, and sets the rotation.
|
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. |
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. |
boolean |
setLocationSafely(Location<World> location)
Sets the location of this entity using a safe one from
TeleportHelper.getSafeLocation(Location) . |
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.
|
void |
setTransform(Transform<World> transform)
Sets the entity transform.
|
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).
|
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).
|
getUniqueId
getProperties, getProperty, setRawData, validateRawData
toContainer
EntityType getType()
World getWorld()
EntitySnapshot createSnapshot()
EntitySnapshot
containing the EntityType
and data of this entity.void setLocation(Location<World> location)
location
- The location to setboolean setLocationSafely(Location<World> location)
TeleportHelper.getSafeLocation(Location)
. This is equivalent to a
teleport and also moves this entity's passengers.location
- The location to setcom.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 tovoid 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 setboolean 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 setvoid 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 relativelyboolean 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 relativelycom.flowpowered.math.vector.Vector3d getScale()
Vector3d.ONE
.void setScale(com.flowpowered.math.vector.Vector3d scale)
scale
- The scaleTransform<World> getTransform()
void setTransform(Transform<World> transform)
transform
- The transform to setboolean 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
WorldProperties.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 worldboolean 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
WorldProperties.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 worldboolean isOnGround()
boolean isRemoved()
boolean isLoaded()
void remove()
boolean damage(double damage, Cause cause)
Entity
with the given Cause
. It is
imperative that a DamageSource
is included
with the cause for maximum compatibility with plugins and the game
itself.damage
- The damage to dealcause
- The cause of the damage