public final class FabricDimensions extends Object
Modifier and Type | Method and Description |
---|---|
static <E extends net.minecraft.entity.Entity> |
teleport(E teleported,
net.minecraft.world.dimension.DimensionType destination)
Teleports an entity to a different dimension, using custom placement logic.
|
static <E extends net.minecraft.entity.Entity> |
teleport(E teleported,
net.minecraft.world.dimension.DimensionType destination,
EntityPlacer customPlacer)
Teleports an entity to a different dimension, using custom placement logic.
|
public static <E extends net.minecraft.entity.Entity> E teleport(E teleported, net.minecraft.world.dimension.DimensionType destination)
This method behaves as if:
teleported.changeDimension(destination)
If destination
is a FabricDimensionType
, the placement logic used
is FabricDimensionType.getDefaultPlacement()
. If destination
is
the nether or the overworld, the default logic is the vanilla path.
For any other dimension, the default placement behaviour is undefined.
When delegating to a placement logic that uses portals, the entity's lastPortalPosition
,
lastPortalDirectionVector
, and lastPortalDirection
fields should be updated
before calling this method.
After calling this method, teleported
may be invalidated. Callers should use
the returned entity for any further manipulation.
teleported
- the entity to teleportdestination
- the dimension the entity will be teleported toteleport(Entity, DimensionType, EntityPlacer)
public static <E extends net.minecraft.entity.Entity> E teleport(E teleported, net.minecraft.world.dimension.DimensionType destination, EntityPlacer customPlacer)
If customPlacement
is null
, this method behaves as if:
teleported.changeDimension(destination)
The customPlacement
may itself return null
, in which case
the default placement logic for that dimension will be run.
If destination
is a FabricDimensionType
, the default placement logic
is FabricDimensionType.getDefaultPlacement()
. If destination
is the nether
or the overworld, the default logic is the vanilla path.
For any other dimension, the default placement behaviour is undefined.
When delegating to a placement logic that uses portals, the entity's lastPortalPosition
,
lastPortalDirectionVector
, and lastPortalDirection
fields should be updated
before calling this method.
After calling this method, teleported
may be invalidated. Callers should use
the returned entity for any further manipulation.
E
- the type of the teleported entityteleported
- the entity to teleportdestination
- the dimension the entity will be teleported tocustomPlacer
- custom placement logic that will run before the default one,
or null
to use the dimension's default behavior (see FabricDimensionType.getDefaultPlacement()
).IllegalStateException
- if this method is called on a client entity