From dd096a5255307788fc26d94135bb87c85e436f13 Mon Sep 17 00:00:00 2001 From: Thinkofdeath Date: Sat, 29 Nov 2014 20:00:52 +0000 Subject: [PATCH] Improve the invalid block handling --- nms-patches/ChunkRegionLoader.patch | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/nms-patches/ChunkRegionLoader.patch b/nms-patches/ChunkRegionLoader.patch index 01fdd1e306..0330fc2b25 100644 --- a/nms-patches/ChunkRegionLoader.patch +++ b/nms-patches/ChunkRegionLoader.patch @@ -1,5 +1,5 @@ ---- ../work/decompile-8eb82bde//net/minecraft/server/ChunkRegionLoader.java 2014-11-29 17:31:14.897318138 +0000 -+++ src/main/java/net/minecraft/server/ChunkRegionLoader.java 2014-11-29 17:31:08.453318281 +0000 +--- ../work/decompile-8eb82bde//net/minecraft/server/ChunkRegionLoader.java 2014-11-29 20:00:36.009119253 +0000 ++++ src/main/java/net/minecraft/server/ChunkRegionLoader.java 2014-11-29 20:00:18.677119638 +0000 @@ -23,8 +23,40 @@ public ChunkRegionLoader(File file) { this.e = file; @@ -8,7 +8,7 @@ + // CraftBukkit start + public boolean chunkExists(World world, int i, int j) { + ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j); - ++ + synchronized (this.d) { + if (this.c.contains(chunkcoordintpair)) { + for (int k = 0; k < this.b.size(); ++k) { @@ -18,7 +18,7 @@ + } + } + } -+ + + return RegionFileCache.a(this.e, i, j).chunkExists(i & 31, j & 31); + } + // CraftBukkit end @@ -107,7 +107,7 @@ DataOutputStream dataoutputstream = RegionFileCache.d(this.e, pendingchunktosave.a.x, pendingchunktosave.a.z); NBTCompressedStreamTools.a(pendingchunktosave.b, (DataOutput) dataoutputstream); -@@ -302,8 +358,23 @@ +@@ -302,8 +358,32 @@ int j1 = l >> 8 & 15; int k1 = l >> 4 & 15; int l1 = nibblearray1 != null ? nibblearray1.a(i1, j1, k1) : 0; @@ -124,7 +124,16 @@ + if (Block.d.a(packed) == null) { + Block block = Block.getById(ex << 8 | id); + if (block != null) { -+ data = block.toLegacyData(block.fromLegacyData(data)); ++ try { ++ data = block.toLegacyData(block.fromLegacyData(data)); ++ } catch (Exception ignored) { ++ for (data = 0; data <= 15; data++) { ++ packed = ex << 12 | id << 4 | data; ++ if (Block.d.a(packed) != null) { ++ break; ++ } ++ } ++ } + packed = ex << 12 | id << 4 | data; + } + } @@ -133,7 +142,7 @@ } chunksection.a(achar); -@@ -320,7 +391,13 @@ +@@ -320,7 +400,13 @@ if (nbttagcompound.hasKeyOfType("Biomes", 7)) { chunk.a(nbttagcompound.getByteArray("Biomes")); } @@ -147,7 +156,7 @@ NBTTagList nbttaglist1 = nbttagcompound.getList("Entities", 10); if (nbttaglist1 != null) { -@@ -379,6 +456,6 @@ +@@ -379,6 +465,6 @@ } }