Class FabricDimensions

java.lang.Object
net.fabricmc.fabric.api.dimension.v1.FabricDimensions

public final class FabricDimensions extends Object
This class consists exclusively of static methods that operate on world dimensions.
  • Method Details

    • teleport

      @Nullable public static <E extends Entity> E teleport(E teleported, ServerWorld destination, TeleportTarget target)
      Teleports an entity to a different dimension, placing it at the specified destination.

      Using this method will circumvent Vanilla's portal placement code.

      When teleporting to another dimension, the entity may be replaced with a new entity in the target dimension. This is not the case for players, but needs to be accounted for by the caller.

      Type Parameters:
      E - the type of the teleported entity
      Parameters:
      teleported - the entity to teleport
      destination - the dimension the entity will be teleported to
      target - where the entity will be placed in the target world. As in Vanilla, the target's velocity is not applied to players. If target is null, the entity will not be teleported.
      Returns:
      Returns the teleported entity in the target dimension, which may be a new entity or teleported, depending on the entity type.
      Throws:
      IllegalStateException - if this method is called on a client entity
      API Note:
      this method must be called from the main server thread