mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-15 07:01:36 +08:00
7b0c576798
Allows us much greater control over the Spigot portion of the code and makes us more "proper" Credit to @Dmck2b for originally passing the idea along a while back
64 lines
2.6 KiB
Diff
64 lines
2.6 KiB
Diff
From 556009e8fbd6c78308510f470f9ee787d3e43a75 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 40c878b..6112709 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -783,6 +783,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);
|
|
}
|
|
@@ -792,6 +801,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
|
|
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
|
|
|