aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/1054-Allow-using-old-ender-pearl-behavior.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/1054-Allow-using-old-ender-pearl-behavior.patch')
-rw-r--r--patches/server/1054-Allow-using-old-ender-pearl-behavior.patch62
1 files changed, 62 insertions, 0 deletions
diff --git a/patches/server/1054-Allow-using-old-ender-pearl-behavior.patch b/patches/server/1054-Allow-using-old-ender-pearl-behavior.patch
new file mode 100644
index 0000000000..98de2de07c
--- /dev/null
+++ b/patches/server/1054-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 a2cd4385fca0cf2ec164d06be2732755506c0249..8aff5b7dd14b835788348b22b1fec4d381df816f 100644
+--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
+@@ -834,6 +834,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");
+@@ -3123,7 +3124,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 8de23b39806734c9a413b6d98dbfff25888c1798..1a956249828156fdc273888de59128c3d1a0b898 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;