diff options
author | Nassim Jahnke <[email protected]> | 2024-12-05 11:18:29 +0100 |
---|---|---|
committer | Nassim Jahnke <[email protected]> | 2024-12-05 12:20:56 +0100 |
commit | e4e24f3335609b38f460ced71d18babcf11bf9cb (patch) | |
tree | 51880d664b3444ce26d6f8cdeb3b8219e5616fca /patches/server/0587-Do-not-run-close-logic-for-inventories-on-chunk-unlo.patch | |
parent | c54c062e6ff742445bf7749c84106ca67090172d (diff) | |
download | Paper-e4e24f3335609b38f460ced71d18babcf11bf9cb.tar.gz Paper-e4e24f3335609b38f460ced71d18babcf11bf9cb.zip |
Move around patches again
Diffstat (limited to 'patches/server/0587-Do-not-run-close-logic-for-inventories-on-chunk-unlo.patch')
-rw-r--r-- | patches/server/0587-Do-not-run-close-logic-for-inventories-on-chunk-unlo.patch | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/patches/server/0587-Do-not-run-close-logic-for-inventories-on-chunk-unlo.patch b/patches/server/0587-Do-not-run-close-logic-for-inventories-on-chunk-unlo.patch new file mode 100644 index 0000000000..9cf58cf3c8 --- /dev/null +++ b/patches/server/0587-Do-not-run-close-logic-for-inventories-on-chunk-unlo.patch @@ -0,0 +1,68 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf <[email protected]> +Date: Thu, 11 Mar 2021 03:03:32 -0800 +Subject: [PATCH] Do not run close logic for inventories on chunk unload + +Still call the event and change the active container though. We +want to avoid close logic because it's possible to load the +chunk through it. This should also be OK from a leak prevention/ +state desync POV because the TE is getting unloaded anyways. + +diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java +index 75d0143556dad6e830d3defdd9afecfd7587cdfa..1301622961ffdcfcccc9658a0e4498bc04ad93f5 100644 +--- a/src/main/java/net/minecraft/server/level/ServerLevel.java ++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +@@ -1245,9 +1245,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + // Spigot Start + for (net.minecraft.world.level.block.entity.BlockEntity tileentity : chunk.getBlockEntities().values()) { + if (tileentity instanceof net.minecraft.world.Container) { ++ // Paper start - this area looks like it can load chunks, change the behavior ++ // chests for example can apply physics to the world ++ // so instead we just change the active container and call the event + for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((net.minecraft.world.Container) tileentity).getViewers())) { +- h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason ++ ((org.bukkit.craftbukkit.entity.CraftHumanEntity) h).getHandle().closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason + } ++ // Paper end - this area looks like it can load chunks, change the behavior + } + } + // Spigot End +diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java +index 2392b30ef6cc2050be28f6dbd1d922227ab4a490..0401e274a600b87c4c983a90819a17c9dfbd7172 100644 +--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java ++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +@@ -1966,6 +1966,18 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { + this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId)); + this.doCloseContainer(); + } ++ // Paper start - special close for unloaded inventory ++ @Override ++ public void closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) { ++ // copied from above ++ CraftEventFactory.handleInventoryCloseEvent(this, reason); // CraftBukkit ++ // Paper end ++ // copied from below ++ this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId)); ++ this.containerMenu = this.inventoryMenu; ++ // do not run close logic ++ } ++ // Paper end - special close for unloaded inventory + + @Override + public void doCloseContainer() { +diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java +index 4e33c6c612939e6970d5984825115768ebb6a5ea..81e3072ac80623db47ddc0b9c52e0e56dab9e10e 100644 +--- a/src/main/java/net/minecraft/world/entity/player/Player.java ++++ b/src/main/java/net/minecraft/world/entity/player/Player.java +@@ -547,6 +547,11 @@ public abstract class Player extends LivingEntity { + this.containerMenu = this.inventoryMenu; + } + // Paper end - Inventory close reason ++ // Paper start - special close for unloaded inventory ++ public void closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) { ++ this.containerMenu = this.inventoryMenu; ++ } ++ // Paper end - special close for unloaded inventory + + public void closeContainer() { + this.containerMenu = this.inventoryMenu; |