From 9e1b8e72eedbec44610026b86e83afbac224c5ff Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Sat, 5 Dec 2020 23:05:25 -0600 Subject: [PATCH] Clean up teleport outside border patch Add sleeping, inventory, and toWorld checks --- ...leport-to-spawn-if-outside-world-bor.patch | 43 +++++++++++++++---- .../0100-Totems-work-in-inventory.patch | 4 +- patches/server/0114-Ridables.patch | 12 +++--- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/patches/server/0093-Add-option-to-teleport-to-spawn-if-outside-world-bor.patch b/patches/server/0093-Add-option-to-teleport-to-spawn-if-outside-world-bor.patch index 3ced1df9b..32419e171 100644 --- a/patches/server/0093-Add-option-to-teleport-to-spawn-if-outside-world-bor.patch +++ b/patches/server/0093-Add-option-to-teleport-to-spawn-if-outside-world-bor.patch @@ -5,23 +5,48 @@ Subject: [PATCH] Add option to teleport to spawn if outside world border diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index 27838680a2..bdb1cfac61 100644 +index 27838680a2..0d67c9c6cc 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java -@@ -277,6 +277,13 @@ public abstract class EntityLiving extends Entity { +@@ -277,6 +277,7 @@ public abstract class EntityLiving extends Entity { double d1 = this.world.getWorldBorder().getDamageAmount(); if (d1 > 0.0D) { -+ // Purpur start -+ if (world.purpurConfig.teleportIfOutsideBorder && this instanceof EntityPlayer) { -+ this.ejectPassengers(); -+ this.stopRiding(true); -+ ((EntityPlayer) this).playerConnection.teleport(MCUtil.toLocation(world, world.getSpawn())); -+ } else -+ // Purpur end ++ if (world.purpurConfig.teleportIfOutsideBorder && this instanceof EntityPlayer) { ((EntityPlayer) this).teleport(MCUtil.toLocation(world, world.getSpawn())); return; } // Purpur this.damageEntity(DamageSource.STUCK, (float) Math.max(1, MathHelper.floor(-d0 * d1))); } } +diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java +index 36168d0f7c..69be072e76 100644 +--- a/src/main/java/net/minecraft/server/EntityPlayer.java ++++ b/src/main/java/net/minecraft/server/EntityPlayer.java +@@ -2366,4 +2366,26 @@ public class EntityPlayer extends EntityHuman implements ICrafting { + return (CraftPlayer) super.getBukkitEntity(); + } + // CraftBukkit end ++ ++ // Purpur start ++ public void teleport(Location to) { ++ this.ejectPassengers(); ++ this.stopRiding(true); ++ ++ if (this.isSleeping()) { ++ this.wakeup(true, false); ++ } ++ ++ if (this.activeContainer != this.defaultContainer) { ++ this.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT); ++ } ++ ++ WorldServer toWorld = ((CraftWorld) to.getWorld()).getHandle(); ++ if (this.world == toWorld) { ++ this.playerConnection.teleport(to); ++ } else { ++ this.server.getPlayerList().moveToWorld(this, toWorld, true, to, !toWorld.paperConfig.disableTeleportationSuffocationCheck); ++ } ++ } ++ // Purpur end + } diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java index 8126603aab..cc0752f253 100644 --- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java diff --git a/patches/server/0100-Totems-work-in-inventory.patch b/patches/server/0100-Totems-work-in-inventory.patch index e283548ef..1cc7e959e 100644 --- a/patches/server/0100-Totems-work-in-inventory.patch +++ b/patches/server/0100-Totems-work-in-inventory.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Totems work in inventory diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index bdb1cfac61..a7e0f8fe3d 100644 +index 0d67c9c6cc..0fe6f90ea6 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java -@@ -1324,6 +1324,19 @@ public abstract class EntityLiving extends Entity { +@@ -1318,6 +1318,19 @@ public abstract class EntityLiving extends Entity { } } diff --git a/patches/server/0114-Ridables.patch b/patches/server/0114-Ridables.patch index cdc0a5262..ddc916358 100644 --- a/patches/server/0114-Ridables.patch +++ b/patches/server/0114-Ridables.patch @@ -2371,10 +2371,10 @@ index bdff236883..9ee03b233b 100644 float f1 = 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F; diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index a7e0f8fe3d..17c3b43c9b 100644 +index 0fe6f90ea6..ce29695c69 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java -@@ -465,7 +465,7 @@ public abstract class EntityLiving extends Entity { +@@ -459,7 +459,7 @@ public abstract class EntityLiving extends Entity { @Override public boolean bt() { @@ -2383,7 +2383,7 @@ index a7e0f8fe3d..17c3b43c9b 100644 } protected void cU() { -@@ -2185,7 +2185,7 @@ public abstract class EntityLiving extends Entity { +@@ -2179,7 +2179,7 @@ public abstract class EntityLiving extends Entity { return 0.42F * this.getBlockJumpFactor(); } @@ -2392,7 +2392,7 @@ index a7e0f8fe3d..17c3b43c9b 100644 float f = this.dJ(); if (this.hasEffect(MobEffects.JUMP)) { -@@ -2434,10 +2434,12 @@ public abstract class EntityLiving extends Entity { +@@ -2428,10 +2428,12 @@ public abstract class EntityLiving extends Entity { return this.onGround ? this.dN() * (0.21600002F / (f * f * f)) : this.aE; } @@ -2405,7 +2405,7 @@ index a7e0f8fe3d..17c3b43c9b 100644 public void q(float f) { this.bu = f; } -@@ -2837,6 +2839,20 @@ public abstract class EntityLiving extends Entity { +@@ -2831,6 +2833,20 @@ public abstract class EntityLiving extends Entity { } } // Purpur end @@ -3210,7 +3210,7 @@ index a3a428da99..cf7de01271 100644 this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false)); diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 563eb77ce3..2992c51a28 100644 +index 05f9a81854..b5f6a98fe4 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -506,6 +506,15 @@ public class EntityPlayer extends EntityHuman implements ICrafting {