From a2e007c47a880ab94c5f95b19f69ea2bb008b3db Mon Sep 17 00:00:00 2001 From: Prototik Date: Thu, 14 May 2015 22:38:38 +0700 Subject: [PATCH] Correctly handle cross world entity teleportation Spigot patch: 0124-Cross-World-Entity-Teleportation.patch --- build.gradle | 2 +- .../event/player/PlayerTeleportEvent.java.patch | 15 ++++++++++++++- .../bukkit/craftbukkit/entity/CraftEntity.java | 8 +++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 787c676..01c880d 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,7 @@ archivesBaseName = 'kcauldron' ext.mcVersion = "1.7.10" ext.cauldronVersion = "3" ext.forgeVersion = "1403" -ext.revision = "59" +ext.revision = "60" version = "${mcVersion}-${cauldronVersion}.${forgeVersion}.${revision}" launch4j { diff --git a/patches/org/bukkit/event/player/PlayerTeleportEvent.java.patch b/patches/org/bukkit/event/player/PlayerTeleportEvent.java.patch index be76ae5..6344581 100644 --- a/patches/org/bukkit/event/player/PlayerTeleportEvent.java.patch +++ b/patches/org/bukkit/event/player/PlayerTeleportEvent.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/org/bukkit/event/player/PlayerTeleportEvent.java +++ ../src-work/minecraft/org/bukkit/event/player/PlayerTeleportEvent.java -@@ -55,7 +55,14 @@ +@@ -55,11 +55,27 @@ * portal */ END_PORTAL, @@ -15,3 +15,16 @@ * Indicates the teleportation was caused by an event not covered by * this enum */ + UNKNOWN; ++ ++ public boolean isPortal() { ++ switch(this) { ++ case NETHER_PORTAL: ++ case END_PORTAL: ++ return true; ++ } ++ return false; ++ } + } + + @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index bfbc44e..7385be6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -413,7 +413,13 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return false; } - entity.worldObj = ((CraftWorld) location.getWorld()).getHandle(); + // Spigot start + net.minecraft.world.WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle(); + if (newWorld != entity.worldObj) { + entity.teleportTo(location, cause.isPortal()); + return true; + } + // Spigot entity.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); // entity.setLocation() throws no event, and so cannot be cancelled return true;