2014-08-31 18:56:05 +00:00
|
|
|
From 13bf7c59fcc316dd8adecba24c0dcbdc5b4ee654 Mon Sep 17 00:00:00 2001
|
2014-07-21 20:46:54 +00:00
|
|
|
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/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
2014-08-06 23:00:55 +00:00
|
|
|
index 40c878b..ab0af12 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
2014-08-06 23:00:55 +00:00
|
|
|
@@ -783,6 +783,18 @@ public class Chunk {
|
2014-07-21 20:46:54 +00:00
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
TileEntity tileentity = (TileEntity) iterator.next();
|
|
|
|
+ // Spigot Start
|
|
|
|
+ if ( tileentity instanceof IInventory )
|
|
|
|
+ {
|
2014-08-06 23:00:55 +00:00
|
|
|
+ for ( org.bukkit.entity.HumanEntity h : new ArrayList<org.bukkit.entity.HumanEntity>( (List) ( (IInventory) tileentity ).getViewers() ) )
|
2014-07-21 20:46:54 +00:00
|
|
|
+ {
|
2014-08-06 23:00:55 +00:00
|
|
|
+ if ( h instanceof org.bukkit.craftbukkit.entity.CraftHumanEntity )
|
|
|
|
+ {
|
|
|
|
+ ( (org.bukkit.craftbukkit.entity.CraftHumanEntity) h).getHandle().closeInventory();
|
|
|
|
+ }
|
2014-07-21 20:46:54 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Spigot End
|
|
|
|
|
|
|
|
this.world.a(tileentity);
|
|
|
|
}
|
2014-08-06 23:00:55 +00:00
|
|
|
@@ -792,6 +804,18 @@ public class Chunk {
|
2014-07-21 20:46:54 +00:00
|
|
|
java.util.Iterator<Object> iter = this.entitySlices[i].iterator();
|
|
|
|
while (iter.hasNext()) {
|
|
|
|
Entity entity = (Entity) iter.next();
|
|
|
|
+ // Spigot Start
|
|
|
|
+ if ( entity instanceof IInventory )
|
|
|
|
+ {
|
2014-08-06 23:00:55 +00:00
|
|
|
+ for ( org.bukkit.entity.HumanEntity h : new ArrayList<org.bukkit.entity.HumanEntity>( (List) ( (IInventory) entity ).getViewers() ) )
|
2014-07-21 20:46:54 +00:00
|
|
|
+ {
|
2014-08-06 23:00:55 +00:00
|
|
|
+ if ( h instanceof org.bukkit.craftbukkit.entity.CraftHumanEntity )
|
|
|
|
+ {
|
|
|
|
+ ( (org.bukkit.craftbukkit.entity.CraftHumanEntity) h).getHandle().closeInventory();
|
|
|
|
+ }
|
2014-07-21 20:46:54 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 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 13b75ff..bf8e745 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 b(int i) {
|
|
|
|
+ // Spigot Start
|
|
|
|
+ for ( HumanEntity human : new java.util.ArrayList<HumanEntity>( transaction ) )
|
|
|
|
+ {
|
|
|
|
+ human.closeInventory();
|
|
|
|
+ }
|
|
|
|
+ // Spigot End
|
|
|
|
this.b = false;
|
|
|
|
super.b(i);
|
|
|
|
}
|
|
|
|
--
|
|
|
|
1.9.1
|
2014-08-08 22:15:42 +00:00
|
|
|
|