From 7a8b5c8e972137ad02eb50e9ce7da758dab61d99 Mon Sep 17 00:00:00 2001 From: md_5 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/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java index e8d30c5..4879db6 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -690,6 +690,15 @@ public class Chunk { while (iterator.hasNext()) { TileEntity tileentity = (TileEntity) iterator.next(); + // Spigot Start + if ( tileentity instanceof IInventory ) + { + for ( org.bukkit.craftbukkit.entity.CraftHumanEntity h : new ArrayList( (List) ( (IInventory) tileentity ).getViewers() ) ) + { + h.getHandle().closeInventory(); + } + } + // Spigot End this.world.a(tileentity); } @@ -699,6 +708,15 @@ public class Chunk { java.util.Iterator iter = this.entitySlices[i].iterator(); while (iter.hasNext()) { Entity entity = (Entity) iter.next(); + // Spigot Start + if ( entity instanceof IInventory ) + { + for ( org.bukkit.craftbukkit.entity.CraftHumanEntity h : new ArrayList( (List) ( (IInventory) entity ).getViewers() ) ) + { + h.getHandle().closeInventory(); + } + } + // Spigot End // Do not pass along players, as doing so can get them stuck outside of time. // (which for example disables inventory icon updates and prevents block breaking) diff --git a/src/main/java/net/minecraft/server/EntityMinecartContainer.java b/src/main/java/net/minecraft/server/EntityMinecartContainer.java index c207076..8f9f558 100644 --- a/src/main/java/net/minecraft/server/EntityMinecartContainer.java +++ b/src/main/java/net/minecraft/server/EntityMinecartContainer.java @@ -149,6 +149,12 @@ public abstract class EntityMinecartContainer extends EntityMinecartAbstract imp } public void c(int i) { + // Spigot Start + for ( HumanEntity human : new java.util.ArrayList( transaction ) ) + { + human.closeInventory(); + } + // Spigot End this.b = false; super.c(i); } -- 1.8.1.2