papermc/CraftBukkit-Patches/0032-Properly-Close-Inventories.patch

70 lines
3 KiB
Diff
Raw Normal View History

2015-02-26 10:40:16 +00:00
From e59b9c6809c13422cad7fe4d06bef09ed52b0451 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
index 2e715b3..49eab04 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -796,6 +796,18 @@ public class Chunk {
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() ) )
+ {
+ if ( h instanceof org.bukkit.craftbukkit.entity.CraftHumanEntity )
+ {
+ ( (org.bukkit.craftbukkit.entity.CraftHumanEntity) h).getHandle().closeInventory();
+ }
+ }
+ }
+ // Spigot End
2014-11-28 01:17:45 +00:00
this.world.b(tileentity);
}
@@ -806,6 +818,18 @@ public class Chunk {
2014-11-28 01:17:45 +00:00
java.util.Iterator<Entity> iter = newList.iterator();
while (iter.hasNext()) {
2014-11-28 01:17:45 +00:00
Entity entity = iter.next();
+ // 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() ) )
+ {
+ if ( h instanceof org.bukkit.craftbukkit.entity.CraftHumanEntity )
+ {
+ ( (org.bukkit.craftbukkit.entity.CraftHumanEntity) 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-11-28 01:17:45 +00:00
index ab1b3a5..bf882de 100644
--- a/src/main/java/net/minecraft/server/EntityMinecartContainer.java
+++ b/src/main/java/net/minecraft/server/EntityMinecartContainer.java
2014-11-28 01:17:45 +00:00
@@ -124,6 +124,12 @@ public abstract class EntityMinecartContainer extends EntityMinecartAbstract imp
}
2014-11-28 01:17:45 +00:00
public void c(int i) {
+ // 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-11-28 01:17:45 +00:00
2.1.0