1
0
forked from xjboss/KCauldronX

Correctly handle cross world entity teleportation

Spigot patch: 0124-Cross-World-Entity-Teleportation.patch
This commit is contained in:
Prototik 2015-05-14 22:38:38 +07:00
parent 3fceb97d3a
commit a2e007c47a
3 changed files with 22 additions and 3 deletions

View File

@ -47,7 +47,7 @@ archivesBaseName = 'kcauldron'
ext.mcVersion = "1.7.10" ext.mcVersion = "1.7.10"
ext.cauldronVersion = "3" ext.cauldronVersion = "3"
ext.forgeVersion = "1403" ext.forgeVersion = "1403"
ext.revision = "59" ext.revision = "60"
version = "${mcVersion}-${cauldronVersion}.${forgeVersion}.${revision}" version = "${mcVersion}-${cauldronVersion}.${forgeVersion}.${revision}"
launch4j { launch4j {

View File

@ -1,6 +1,6 @@
--- ../src-base/minecraft/org/bukkit/event/player/PlayerTeleportEvent.java --- ../src-base/minecraft/org/bukkit/event/player/PlayerTeleportEvent.java
+++ ../src-work/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 * portal
*/ */
END_PORTAL, END_PORTAL,
@ -15,3 +15,16 @@
* Indicates the teleportation was caused by an event not covered by * Indicates the teleportation was caused by an event not covered by
* this enum * this enum
*/ */
UNKNOWN;
+
+ public boolean isPortal() {
+ switch(this) {
+ case NETHER_PORTAL:
+ case END_PORTAL:
+ return true;
+ }
+ return false;
+ }
}
@Override

View File

@ -413,7 +413,13 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return false; 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.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
// entity.setLocation() throws no event, and so cannot be cancelled // entity.setLocation() throws no event, and so cannot be cancelled
return true; return true;