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

64 lines
2.6 KiB
Diff
Raw Normal View History

2013-12-13 01:10:33 +01:00
From 7e52e67df82bd2d4376cb31ba475cc8e2fb8d89f 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/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
2013-12-13 01:10:33 +01:00
index efe7ca5..a4adc56 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
2013-12-01 04:40:53 +01:00
@@ -749,6 +749,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<org.bukkit.craftbukkit.entity.CraftHumanEntity>( (List) ( (IInventory) tileentity ).getViewers() ) )
+ {
+ h.getHandle().closeInventory();
+ }
+ }
+ // Spigot End
this.world.a(tileentity);
}
2013-12-01 04:40:53 +01:00
@@ -758,6 +767,15 @@ public class Chunk {
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
2013-12-01 04:40:53 +01:00
index 1d997e1..1c64d42 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
}
2013-07-02 05:03:56 +02:00
public void b(int i) {
+ // Spigot Start
2013-06-29 05:46:41 +02:00
+ for ( HumanEntity human : new java.util.ArrayList<HumanEntity>( transaction ) )
+ {
2013-06-28 06:16:30 +02:00
+ human.closeInventory();
+ }
+ // Spigot End
this.b = false;
2013-07-02 05:03:56 +02:00
super.b(i);
}
--
2013-12-01 04:40:53 +01:00
1.8.3.2