MCPcopy Create free account
hub / github.com/McJty/TutorialV3 / teleport

Method teleport

src/main/java/com/example/tutorialv3/varia/Tools.java:26–39  ·  view source on GitHub ↗
(ServerPlayer entity, ServerLevel destination, BlockPos pos, boolean findTop)

Source from the content-addressed store, hash-verified

24 }
25
26 public static void teleport(ServerPlayer entity, ServerLevel destination, BlockPos pos, boolean findTop) {
27 entity.changeDimension(destination, new ITeleporter() {
28 @Override
29 public Entity placeEntity(Entity entity, ServerLevel currentWorld, ServerLevel destWorld, float yaw, Function<Boolean, Entity> repositionEntity) {
30 entity = repositionEntity.apply(false);
31 int y = pos.getY();
32 if (findTop) {
33 y = destination.getHeight(Heightmap.Types.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
34 }
35 entity.teleportTo(pos.getX(), y, pos.getZ());
36 return entity;
37 }
38 });
39 }
40
41}

Callers 1

teleportToMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected