aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0824-Fix-merchant-inventory-not-closing-on-entity-removal.patch
blob: f2ef36d722e5944295794b19fcd4bee61a9ac8b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
index 710a1064cec9c7ec93e1258b0786e74ab9af0c12..d572a0883938cd117d11a2bb0ee4e0d5b5e65361 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
                 }