Interface Entity

All Superinterfaces:
CommandSource, HoverEventSource<HoverEvent.ShowEntity>, SchedulerSource, Sound.Emitter, Sound.Source.Provider
All Known Subinterfaces:
Damageable, LivingEntity, Mob, Player

Anything living in a World: players, mobs, items, projectiles.

An entity is bound to the region thread owning its chunk. Read its state freely, but change it from that thread, through SchedulerSource.execute(Runnable) when needed.

Since:
0.1.0
  • Method Details

    • entityId

      int entityId()
      Returns the network identifier of this entity, unique while the server runs.
      Returns:
      the network identifier of this entity, unique while the server runs
      Since:
      0.1.0
    • uuid

      UUID uuid()
      Returns the persistent identity of this entity.
      Returns:
      the persistent identity of this entity
      Since:
      0.1.0
    • displayName

      Component displayName()
      Returns the name shown for this entity, its custom name or its type name.
      Returns:
      the name shown for this entity, its custom name or its type name
      Since:
      0.1.0
    • type

      EntityType type()
      Returns the type of this entity.
      Returns:
      the type of this entity
      Since:
      0.1.0
    • world

      World world()
      Returns the world this entity is in.
      Returns:
      the world this entity is in
      Since:
      0.1.0
    • location

      Location location()
      Returns the current position and orientation of this entity.
      Specified by:
      location in interface CommandSource
      Returns:
      the current position and orientation of this entity
      Since:
      0.1.0
    • chunk

      default ChunkPos chunk()
      Returns the position of the chunk holding this entity.
      Returns:
      the position of the chunk holding this entity
      Since:
      0.1.0
    • isRemoved

      boolean isRemoved()
      Returns true once this entity has left its world for good.
      Returns:
      true once this entity has left its world for good
      Since:
      0.1.0
    • remove

      void remove()
      Removes this entity from its world for good.
      Since:
      0.1.0
    • teleport

      CompletableFuture<Boolean> teleport(Location location)
      Teleports this entity to the given location within its current world.
      Parameters:
      location - the destination position and orientation
      Returns:
      a future completing with true if the teleport happened, false if it was refused (for example because the entity has been removed)
      Since:
      0.1.0
    • teleport

      CompletableFuture<Boolean> teleport(World world, Location location)
      Teleports this entity to the given location, moving it to world when that differs from its current world.

      Cross-world teleports relocate the entity between worlds and, for players, trigger the client-side dimension change. The call is refused, completing with false, when the entity is removed or the destination world cannot host it.

      Parameters:
      world - the destination world
      location - the destination position and orientation
      Returns:
      a future completing with true if the teleport happened, false if it was refused
      Since:
      0.1.0
    • teleport

      default CompletableFuture<Boolean> teleport(double x, double y, double z)
      Teleports this entity within its current world, keeping its orientation.
      Parameters:
      x - the destination x coordinate
      y - the destination y coordinate
      z - the destination z coordinate
      Returns:
      a future completing with true if the teleport happened, false if it was refused
      Since:
      0.1.0
    • teleport

      default CompletableFuture<Boolean> teleport(Entity target)
      Teleports this entity to another entity, moving worlds when needed.
      Parameters:
      target - the entity to teleport to
      Returns:
      a future completing with true if the teleport happened, false if it was refused
      Since:
      0.1.0