diff options
author | Jason Penilla <[email protected]> | 2024-10-27 12:49:06 -0700 |
---|---|---|
committer | Jason Penilla <[email protected]> | 2024-10-27 12:52:47 -0700 |
commit | db9d12792fbe40dc56ea2e02d8d563dc128539f2 (patch) | |
tree | 4331d3733806e884d3da95882db952e71a88ba7c /patches/server/1055-Allow-using-old-ender-pearl-behavior.patch | |
parent | 29bf7beba9a16467abc7d901d92c08130c18a9f5 (diff) | |
download | Paper-db9d12792fbe40dc56ea2e02d8d563dc128539f2.tar.gz Paper-db9d12792fbe40dc56ea2e02d8d563dc128539f2.zip |
Allow using old ender pearl behavior & apply ender pearl exploit patch1.21.3-legacy-ender-pearls
When enabled, ender pearls will not load chunks and will save to the world instead of the player.
Also changes the exploit config to be default false, as it only makes sense when legacy behavior is enabled.
Diffstat (limited to 'patches/server/1055-Allow-using-old-ender-pearl-behavior.patch')
-rw-r--r-- | patches/server/1055-Allow-using-old-ender-pearl-behavior.patch | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/patches/server/1055-Allow-using-old-ender-pearl-behavior.patch b/patches/server/1055-Allow-using-old-ender-pearl-behavior.patch new file mode 100644 index 0000000000..116240194a --- /dev/null +++ b/patches/server/1055-Allow-using-old-ender-pearl-behavior.patch @@ -0,0 +1,62 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jason Penilla <[email protected]> +Date: Sun, 27 Oct 2024 12:36:53 -0700 +Subject: [PATCH] Allow using old ender pearl behavior + +When enabled, ender pearls will not load chunks and will save to the world instead of the player. + +== AT == +public net.minecraft.world.entity.projectile.Projectile cachedOwner + +diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java +index 4e4e5b7e8c387cf13cf5bc5e39d334c3222c9103..cffbd3300967e5d80b5973b35a76235bb2aa1b73 100644 +--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java ++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +@@ -836,6 +836,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple + + while (iterator.hasNext()) { + ThrownEnderpearl entityenderpearl = (ThrownEnderpearl) iterator.next(); ++ if (entityenderpearl.level().paperConfig().misc.legacyEnderPearlBehavior) continue; // Paper - Allow using old ender pearl behavior + + if (entityenderpearl.isRemoved()) { + ServerPlayer.LOGGER.warn("Trying to save removed ender pearl, skipping"); +@@ -3146,7 +3147,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple + } + + public static long placeEnderPearlTicket(ServerLevel world, ChunkPos chunkPos) { +- world.getChunkSource().addRegionTicket(TicketType.ENDER_PEARL, chunkPos, 2, chunkPos); ++ if (!world.paperConfig().misc.legacyEnderPearlBehavior) world.getChunkSource().addRegionTicket(TicketType.ENDER_PEARL, chunkPos, 2, chunkPos); // Paper - Allow using old ender pearl behavior + return TicketType.ENDER_PEARL.timeout(); + } + +diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java +index cf42042c754b30e41c0ec8a6a15195369bdbd199..1fcd9cd9344b0d2c4752042b07142db7d727dce8 100644 +--- a/src/main/java/net/minecraft/server/players/PlayerList.java ++++ b/src/main/java/net/minecraft/server/players/PlayerList.java +@@ -602,7 +602,13 @@ public abstract class PlayerList { + while (iterator.hasNext()) { + ThrownEnderpearl entityenderpearl = (ThrownEnderpearl) iterator.next(); + ++ // Paper start - Allow using old ender pearl behavior ++ if (!entityenderpearl.level().paperConfig().misc.legacyEnderPearlBehavior) { + entityenderpearl.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER, EntityRemoveEvent.Cause.PLAYER_QUIT); // CraftBukkit - add Bukkit remove cause ++ } else { ++ entityenderpearl.cachedOwner = null; ++ } ++ // Paper end - Allow using old ender pearl behavior + } + + worldserver.removePlayerImmediately(entityplayer, Entity.RemovalReason.UNLOADED_WITH_PLAYER); +diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +index 5f790dd24f2bdae827c6dc597064b9b265089751..bd2684528157f928460f2143dd71a48e11983123 100644 +--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java ++++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +@@ -252,7 +252,7 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { + Entity entity = super.teleport(teleportTarget); + + if (entity != null) { +- entity.placePortalTicket(BlockPos.containing(entity.position())); ++ if (!this.level().paperConfig().misc.legacyEnderPearlBehavior) entity.placePortalTicket(BlockPos.containing(entity.position())); // Paper - Allow using old ender pearl behavior + } + + return entity; |