From 8982e3f33e4c1d47fe31d71c8dc25e929d7b99d7 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 22 May 2016 11:36:38 +1000 Subject: [PATCH] SPIGOT-2297: Reintroduce getChunkIfLoaded --- nms-patches/ChunkProviderServer.patch | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/nms-patches/ChunkProviderServer.patch b/nms-patches/ChunkProviderServer.patch index f33c3aadcc..c3349bd155 100644 --- a/nms-patches/ChunkProviderServer.patch +++ b/nms-patches/ChunkProviderServer.patch @@ -18,7 +18,7 @@ public final ChunkGenerator chunkGenerator; private final IChunkLoader chunkLoader; public final Long2ObjectMap chunks = new Long2ObjectOpenHashMap(8192); -@@ -69,19 +75,68 @@ +@@ -69,19 +75,74 @@ Chunk chunk = this.getLoadedChunkAt(i, j); if (chunk == null) { @@ -45,6 +45,12 @@ return chunk; } ++ // CraftBukkit start ++ public Chunk getChunkIfLoaded(int x, int z) { ++ return chunks.get(ChunkCoordIntPair.a(x, z)); ++ } ++ // CraftBukkit end ++ public Chunk getChunkAt(int i, int j) { - Chunk chunk = this.getOrLoadChunkAt(i, j); + return getChunkAt(i, j, null); @@ -55,7 +61,7 @@ + } + + public Chunk getChunkAt(int i, int j, Runnable runnable, boolean generate) { -+ Chunk chunk = chunks.get(ChunkCoordIntPair.a(i, j)); ++ Chunk chunk = getChunkIfLoaded(i, j); + ChunkRegionLoader loader = null; + + if (this.chunkLoader instanceof ChunkRegionLoader) { @@ -89,7 +95,7 @@ if (chunk == null) { long k = ChunkCoordIntPair.a(i, j); -@@ -97,9 +152,37 @@ +@@ -97,9 +158,37 @@ crashreportsystemdetails.a("Generator", (Object) this.chunkGenerator); throw new ReportedException(crashreport); } @@ -116,7 +122,7 @@ + continue; + } + -+ Chunk neighbor = this.getLoadedChunkAt(chunk.locX + x, chunk.locZ + z); ++ Chunk neighbor = this.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z); + if (neighbor != null) { + neighbor.setNeighborLoaded(-x, -z); + chunk.setNeighborLoaded(x, z); @@ -127,7 +133,7 @@ chunk.loadNearby(this, this.chunkGenerator); } -@@ -146,10 +229,12 @@ +@@ -146,10 +235,12 @@ public boolean a(boolean flag) { int i = 0; @@ -143,7 +149,7 @@ if (flag) { this.saveChunkNOP(chunk); -@@ -182,6 +267,29 @@ +@@ -182,6 +273,29 @@ Chunk chunk = (Chunk) this.chunks.get(olong); if (chunk != null && chunk.d) { @@ -161,7 +167,7 @@ + continue; + } + -+ Chunk neighbor = this.chunks.get(ChunkCoordIntPair.a(chunk.locX + x, chunk.locZ + z)); ++ Chunk neighbor = this.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z); + if (neighbor != null) { + neighbor.setNeighborUnloaded(-x, -z); + chunk.setNeighborUnloaded(x, z);