2015-02-28 11:36:22 +00:00
|
|
|
From 1aee6e97da0635b4c3df6e10290b98ee9ae03850 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
|
2015-02-28 11:36:22 +00:00
|
|
|
index ab971cf..5f07158 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
|
2015-02-28 11:36:22 +00:00
|
|
|
@@ -820,6 +820,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-11-28 01:17:45 +00:00
|
|
|
+ for ( org.bukkit.entity.HumanEntity h : Lists.<org.bukkit.entity.HumanEntity>newArrayList((List<org.bukkit.entity.HumanEntity>) ( (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
|
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
this.world.b(tileentity);
|
2014-07-21 20:46:54 +00:00
|
|
|
}
|
2015-02-28 11:36:22 +00:00
|
|
|
@@ -830,6 +842,18 @@ public class Chunk {
|
2014-11-28 01:17:45 +00:00
|
|
|
java.util.Iterator<Entity> iter = newList.iterator();
|
2014-07-21 20:46:54 +00:00
|
|
|
while (iter.hasNext()) {
|
2014-11-28 01:17:45 +00:00
|
|
|
Entity entity = iter.next();
|
2014-07-21 20:46:54 +00:00
|
|
|
+ // Spigot Start
|
|
|
|
+ if ( entity instanceof IInventory )
|
|
|
|
+ {
|
2014-11-28 01:17:45 +00:00
|
|
|
+ for ( org.bukkit.entity.HumanEntity h : Lists.<org.bukkit.entity.HumanEntity>newArrayList( (List<org.bukkit.entity.HumanEntity>) ( (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
|
2015-02-28 11:36:22 +00:00
|
|
|
index 712018a..17b5714 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityMinecartContainer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityMinecartContainer.java
|
2015-02-28 11:36:22 +00:00
|
|
|
@@ -127,6 +127,12 @@ public abstract class EntityMinecartContainer extends EntityMinecartAbstract imp
|
2014-07-21 20:46:54 +00:00
|
|
|
}
|
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
public void c(int i) {
|
2014-07-21 20:46:54 +00:00
|
|
|
+ // Spigot Start
|
|
|
|
+ for ( HumanEntity human : new java.util.ArrayList<HumanEntity>( transaction ) )
|
|
|
|
+ {
|
|
|
|
+ human.closeInventory();
|
|
|
|
+ }
|
|
|
|
+ // Spigot End
|
|
|
|
this.b = false;
|
2014-11-28 01:17:45 +00:00
|
|
|
super.c(i);
|
2014-07-21 20:46:54 +00:00
|
|
|
}
|
|
|
|
--
|
2014-11-28 01:17:45 +00:00
|
|
|
2.1.0
|
2014-08-08 22:15:42 +00:00
|
|
|
|