Teleportation
Entities can be instantaneously teleported to specific positions, synchronously and asynchronously with the
teleport
and
teleportAsync
API.
entity.teleport(location); // loads chunks synchronously and teleports the entity
entity.teleportAsync(location).thenAccept(success -> { // loads chunks asynchronously and teleports the entity // this code is ran when the teleport completes // the Future is completed on the main thread, so it is safe to use the API here
if (success) { // the entity was teleported successfully! }});
Look at
Section titled “Look at”The lookAt
API allows you to make a player look at a certain position or entity.
player.lookAt( position, LookAnchor.EYES // the player's eyes will be facing the position);
player.lookAt( entity, LookAnchor.EYES // the player's eyes will be facing the entity LookAnchor.FEET // the player will be facing the entity's feet);
Teleport flags
Section titled “Teleport flags”Teleport flags offer a way to teleport entities whilst being able to customize behavior. This allows you to do things like teleport players using relative flags and being able to retain passengers.
All available teleport flags can be found in the TeleportFlag
class.
Relative teleportation
Section titled “Relative teleportation”Teleport a player relatively, preventing velocity from being reset in the X, Y and Z axes.
player.teleport( location, TeleportFlag.Relative.VELOCITY_X, TeleportFlag.Relative.VELOCITY_Y, TeleportFlag.Relative.VELOCITY_Z);
Retaining passengers
Section titled “Retaining passengers”Teleport an entity with the RETAIN_PASSENGERS
flag,
allowing its passengers to be transferred with the entity.
entity.teleport(location, TeleportFlag.EntityState.RETAIN_PASSENGERS);