From 889d211068967cb0e19a41193abc5e61a2573fde Mon Sep 17 00:00:00 2001 From: Robotia Date: Fri, 29 Jan 2016 10:25:14 -0500 Subject: [PATCH] Finish Old Spigot Fix (https://github.com/PaperSpigot/Paper-1.7/blob/master/CraftBukkit-Patches/0035-Properly-Close-Inventories.patch) --- .../minecraft/world/chunk/Chunk.java.patch | 62 +++++++++++++++---- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/patches/net/minecraft/world/chunk/Chunk.java.patch b/patches/net/minecraft/world/chunk/Chunk.java.patch index 5ff7522..35a2e02 100644 --- a/patches/net/minecraft/world/chunk/Chunk.java.patch +++ b/patches/net/minecraft/world/chunk/Chunk.java.patch @@ -239,7 +239,32 @@ } public void removeTileEntity(int p_150805_1_, int p_150805_2_, int p_150805_3_) -@@ -936,6 +1067,21 @@ +@@ -915,6 +1046,7 @@ + while (iterator.hasNext()) + { + Entity entity = (Entity)iterator.next(); ++ + entity.onChunkLoad(); + } + +@@ -931,11 +1063,50 @@ + while (iterator.hasNext()) + { + TileEntity tileentity = (TileEntity)iterator.next(); ++ // Spigot Start ++ if ( tileentity instanceof IInventory ) ++ { ++ for ( org.bukkit.entity.HumanEntity h : new ArrayList( (List) ( (IInventory) tileentity ).getViewers() ) ) ++ { ++ if ( h instanceof org.bukkit.craftbukkit.entity.CraftHumanEntity ) ++ { ++ ( (org.bukkit.craftbukkit.entity.CraftHumanEntity) h).getHandle().closeScreen(); ++ } ++ } ++ } ++ // Spigot End + this.worldObj.func_147457_a(tileentity); + } for (int i = 0; i < this.entityLists.length; ++i) { @@ -249,6 +274,18 @@ + while (iter.hasNext()) + { + Entity entity = (Entity) iter.next(); ++ // Spigot Start ++ if ( entity instanceof IInventory ) ++ { ++ for ( org.bukkit.entity.HumanEntity h : new ArrayList( (List) ( (IInventory) entity ).getViewers() ) ) ++ { ++ if ( h instanceof org.bukkit.craftbukkit.entity.CraftHumanEntity ) ++ { ++ ( (org.bukkit.craftbukkit.entity.CraftHumanEntity) h).getHandle().closeScreen(); ++ } ++ } ++ } ++ // 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) @@ -261,7 +298,7 @@ this.worldObj.unloadEntities(this.entityLists[i]); } MinecraftForge.EVENT_BUS.post(new ChunkEvent.Unload(this)); -@@ -1015,7 +1161,7 @@ +@@ -1015,7 +1186,7 @@ return true; } } @@ -270,7 +307,7 @@ { return true; } -@@ -1025,7 +1171,7 @@ +@@ -1025,7 +1196,7 @@ public Random getRandomWithSeed(long p_76617_1_) { @@ -279,7 +316,7 @@ } public boolean isEmpty() -@@ -1035,6 +1181,7 @@ +@@ -1035,6 +1206,7 @@ public void populateChunk(IChunkProvider p_76624_1_, IChunkProvider p_76624_2_, int p_76624_3_, int p_76624_4_) { @@ -287,7 +324,7 @@ if (!this.isTerrainPopulated && p_76624_1_.chunkExists(p_76624_3_ + 1, p_76624_4_ + 1) && p_76624_1_.chunkExists(p_76624_3_, p_76624_4_ + 1) && p_76624_1_.chunkExists(p_76624_3_ + 1, p_76624_4_)) { p_76624_1_.populate(p_76624_2_, p_76624_3_, p_76624_4_); -@@ -1054,6 +1201,7 @@ +@@ -1054,6 +1226,7 @@ { p_76624_1_.populate(p_76624_2_, p_76624_3_ - 1, p_76624_4_ - 1); } @@ -295,7 +332,7 @@ } public int getPrecipitationHeight(int p_76626_1_, int p_76626_2_) -@@ -1091,7 +1239,7 @@ +@@ -1091,7 +1264,7 @@ { if (this.isGapLightingUpdated && !this.worldObj.provider.hasNoSky && !p_150804_1_) { @@ -304,7 +341,7 @@ } this.field_150815_m = true; -@@ -1184,8 +1332,10 @@ +@@ -1184,8 +1357,10 @@ if ((p_76607_2_ & 1 << l) != 0 && this.storageArrays[l] != null) { nibblearray = this.storageArrays[l].getMetadataArray(); @@ -317,7 +354,7 @@ } } -@@ -1194,8 +1344,10 @@ +@@ -1194,8 +1369,10 @@ if ((p_76607_2_ & 1 << l) != 0 && this.storageArrays[l] != null) { nibblearray = this.storageArrays[l].getBlocklightArray(); @@ -330,7 +367,7 @@ } } -@@ -1206,8 +1358,10 @@ +@@ -1206,8 +1383,10 @@ if ((p_76607_2_ & 1 << l) != 0 && this.storageArrays[l] != null) { nibblearray = this.storageArrays[l].getSkylightArray(); @@ -343,7 +380,7 @@ } } } -@@ -1229,8 +1383,8 @@ +@@ -1229,8 +1408,8 @@ nibblearray = this.storageArrays[l].createBlockMSBArray(); } @@ -354,10 +391,11 @@ } } else if (p_76607_4_ && this.storageArrays[l] != null && this.storageArrays[l].getBlockMSBArray() != null) -@@ -1523,4 +1677,21 @@ +@@ -1523,4 +1702,21 @@ } } } +-} + + /** + * PaperSpigot - Recheck gaps asynchronously. @@ -375,4 +413,4 @@ + } + }); + } - } ++}