mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-09-18 21:33:01 +00:00
44 lines
2.2 KiB
Diff
44 lines
2.2 KiB
Diff
From 7554c9d7defbf3df444055874ff5b660fa167c64 Mon Sep 17 00:00:00 2001
|
|
From: md_5 <md_5@live.com.au>
|
|
Date: Thu, 27 Jun 2013 17:26:09 +1000
|
|
Subject: [PATCH] Properly Close Inventories
|
|
|
|
Properly close inventories when unloading and switching worlds.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
index 21f1fbecf..c1a418351 100644
|
|
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
@@ -1088,6 +1088,15 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
}
|
|
|
|
public void unload(Chunk chunk) {
|
|
+ // Spigot Start
|
|
+ for (net.minecraft.world.level.block.entity.TileEntity tileentity : chunk.getBlockEntities().values()) {
|
|
+ if (tileentity instanceof net.minecraft.world.IInventory) {
|
|
+ for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((net.minecraft.world.IInventory) tileentity).getViewers())) {
|
|
+ h.closeInventory();
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Spigot End
|
|
chunk.clearAllBlockEntities();
|
|
chunk.unregisterTickContainerFromLevel(this);
|
|
}
|
|
@@ -1979,6 +1988,13 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
|
|
public void onTrackingEnd(Entity entity) {
|
|
org.spigotmc.AsyncCatcher.catchOp("entity unregister"); // Spigot
|
|
+ // Spigot Start
|
|
+ if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof EntityPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message
|
|
+ for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((org.bukkit.inventory.InventoryHolder) entity.getBukkitEntity()).getInventory().getViewers())) {
|
|
+ h.closeInventory();
|
|
+ }
|
|
+ }
|
|
+ // Spigot End
|
|
WorldServer.this.getChunkSource().removeEntity(entity);
|
|
if (entity instanceof EntityPlayer) {
|
|
EntityPlayer entityplayer = (EntityPlayer) entity;
|
|
--
|
|
2.40.0
|
|
|