2021-10-16 05:19:08 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
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
2024-10-25 21:24:15 +02:00
index 0485312d40dca972d2477b8d4a4725ff25deacbc..3ca2c0d937dc840ac64fb1efd73dbc5b045bc77d 100644
2021-10-16 05:19:08 +02:00
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
2024-10-23 22:10:14 +02:00
@@ -2328,6 +2328,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
2021-10-16 05:19:08 +02:00
// Spigot end
// Spigot Start
2022-01-09 06:12:05 +01:00
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message
2024-01-19 12:30:04 +01:00
+ // Paper start - Fix merchant inventory not closing on entity removal
2021-10-16 05:19:08 +02:00
+ if (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) {
+ merchant.getTrader().closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED);
+ }
2024-01-19 12:30:04 +01:00
+ // Paper end - Fix merchant inventory not closing on entity removal
2021-10-16 05:19:08 +02:00
for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((org.bukkit.inventory.InventoryHolder) entity.getBukkitEntity()).getInventory().getViewers())) {
2024-01-21 19:37:09 +01:00
h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason
2021-10-16 05:19:08 +02:00
}