From b05a252b025d2cba5615d699c1ccc4f0582fa1c1 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sat, 5 Jan 2019 16:21:07 +1100 Subject: [PATCH] Cross World Entity Teleportation Use Entity.teleportTo for cross-world teleportation in CraftEntity. By: Andrew Krieger --- .../java/org/bukkit/craftbukkit/entity/CraftEntity.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index f58e5f7068..521dd48ed1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -306,7 +306,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { // If this entity is riding another entity, we must dismount before teleporting. entity.stopRiding(); - entity.world = ((CraftWorld) location.getWorld()).getHandle(); + // Let the server handle cross world teleports + if (!location.getWorld().equals(getWorld())) { + entity.teleportTo(location, cause == TeleportCause.NETHER_PORTAL); + return true; + } + // entity.setLocation() throws no event, and so cannot be cancelled entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); // SPIGOT-619: Force sync head rotation also