From 0a16fb81820def3adce5d91f712cdaffb5e087d0 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <15055071+Machine-Maker@users.noreply.github.com> Date: Fri, 15 Oct 2021 20:19:08 -0700 Subject: [PATCH] Fix merchant inventories not closing on entity removal (#6544) --- ...entory-not-closing-on-entity-removal.patch | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 patches/server/0826-Fix-merchant-inventory-not-closing-on-entity-removal.patch diff --git a/patches/server/0826-Fix-merchant-inventory-not-closing-on-entity-removal.patch b/patches/server/0826-Fix-merchant-inventory-not-closing-on-entity-removal.patch new file mode 100644 index 000000000..322591b9c --- /dev/null +++ b/patches/server/0826-Fix-merchant-inventory-not-closing-on-entity-removal.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Thu, 2 Sep 2021 00:24:06 -0700 +Subject: [PATCH] Fix merchant inventory not closing on entity removal + + +diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java +index 96ccf894519fc892e35fbd13ab97fe289236caca..a62abcb2e05198001516cf2402dc7ead09761905 100644 +--- a/src/main/java/net/minecraft/server/level/ServerLevel.java ++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +@@ -2421,6 +2421,11 @@ public class ServerLevel extends Level implements WorldGenLevel { + // Spigot end + // Spigot Start + if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder) { ++ // Paper start ++ if (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) { ++ merchant.getTrader().closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); ++ } ++ // Paper end + for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((org.bukkit.inventory.InventoryHolder) entity.getBukkitEntity()).getInventory().getViewers())) { + h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper + }