Paper/CraftBukkit-Patches/0037-Properly-Close-Inventories.patch

64 lines
2.6 KiB
Diff
Raw Normal View History

2014-04-24 08:27:12 +02:00
From f6c37960464a932e6125c8bd19c8288743eb42ea Mon Sep 17 00:00:00 2001
2014-04-12 06:18:37 +02: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-04-24 08:27:12 +02:00
index a638dba..d0c00db 100644
2014-04-12 06:18:37 +02:00
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
2014-04-24 08:27:12 +02:00
@@ -755,6 +755,15 @@ public class Chunk {
2014-04-12 06:18:37 +02:00
while (iterator.hasNext()) {
TileEntity tileentity = (TileEntity) iterator.next();
+ // Spigot Start
+ if ( tileentity instanceof IInventory )
+ {
+ for ( org.bukkit.craftbukkit.entity.CraftHumanEntity h : new ArrayList<org.bukkit.craftbukkit.entity.CraftHumanEntity>( (List) ( (IInventory) tileentity ).getViewers() ) )
+ {
+ h.getHandle().closeInventory();
+ }
+ }
+ // Spigot End
this.world.a(tileentity);
}
2014-04-24 08:27:12 +02:00
@@ -764,6 +773,15 @@ public class Chunk {
2014-04-12 06:18:37 +02:00
java.util.Iterator<Object> 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<org.bukkit.craftbukkit.entity.CraftHumanEntity>( (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
2014-04-19 01:15:23 +02:00
index b599eeb..2065e5a 100644
2014-04-12 06:18:37 +02:00
--- 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);
}
--
2014-04-19 01:15:23 +02:00
1.9.1
2014-04-12 06:18:37 +02:00