diff options
author | md_5 <git@md-5.net> | 2018-09-26 17:19:16 +1000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-09-26 17:19:16 +1000 |
commit | 1a7f2d109e69f1a2594b91d9ff99fbadb1564b35 (patch) | |
tree | 8544d238f1833b69a0f0b8724d82a1c162c683af | |
parent | 40aed54d112176ab49f1c3c65877e23bcb49f463 (diff) | |
download | craftbukkit-1a7f2d109e69f1a2594b91d9ff99fbadb1564b35.tar craftbukkit-1a7f2d109e69f1a2594b91d9ff99fbadb1564b35.tar.gz craftbukkit-1a7f2d109e69f1a2594b91d9ff99fbadb1564b35.tar.lz craftbukkit-1a7f2d109e69f1a2594b91d9ff99fbadb1564b35.tar.xz craftbukkit-1a7f2d109e69f1a2594b91d9ff99fbadb1564b35.zip |
SPIGOT-4397: isChunkGenerated API
-rw-r--r-- | nms-patches/ChunkProviderServer.patch | 9 | ||||
-rw-r--r-- | nms-patches/ChunkRegionLoader.patch | 36 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 5 |
3 files changed, 33 insertions, 17 deletions
diff --git a/nms-patches/ChunkProviderServer.patch b/nms-patches/ChunkProviderServer.patch index 48ee4e8d..01b456d2 100644 --- a/nms-patches/ChunkProviderServer.patch +++ b/nms-patches/ChunkProviderServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ChunkProviderServer.java +++ b/net/minecraft/server/ChunkProviderServer.java -@@ -18,6 +18,11 @@ +@@ -18,12 +18,17 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -12,6 +12,13 @@ public class ChunkProviderServer implements IChunkProvider { private static final Logger a = LogManager.getLogger(); + public final LongSet unloadQueue = new LongOpenHashSet(); + public final ChunkGenerator<?> chunkGenerator; +- private final IChunkLoader chunkLoader; ++ public final IChunkLoader chunkLoader; // PAIL + public final Long2ObjectMap<Chunk> chunks = Long2ObjectMaps.synchronize(new ChunkMap(8192)); + private Chunk lastChunk; + private final ChunkTaskScheduler chunkScheduler; @@ -36,7 +41,7 @@ this.chunkLoader = ichunkloader; this.chunkGenerator = chunkgenerator; diff --git a/nms-patches/ChunkRegionLoader.patch b/nms-patches/ChunkRegionLoader.patch index b455a239..bff72d18 100644 --- a/nms-patches/ChunkRegionLoader.patch +++ b/nms-patches/ChunkRegionLoader.patch @@ -9,7 +9,7 @@ public ChunkRegionLoader(File file, DataFixer datafixer) { this.c = file; -@@ -40,25 +40,60 @@ +@@ -40,25 +40,64 @@ @Nullable private NBTTagCompound a(GeneratorAccess generatoraccess, int i, int j) throws IOException { @@ -26,7 +26,7 @@ + } + } + -+ if (RegionFileCache.chunkExists(this.c, x, z)) { ++ if (this.chunkExists(x, z)) { + NBTTagCompound nbt = RegionFileCache.read(this.c, x, z); + if (nbt != null) { + NBTTagCompound level = nbt.getCompound("Level"); @@ -42,6 +42,10 @@ + } + + return false; ++ } ++ ++ public boolean chunkExists(int x, int z) { ++ return RegionFileCache.chunkExists(this.c, x, z); } @Nullable @@ -77,7 +81,7 @@ if (k < 1493) { nbttagcompound1 = GameProfileSerializer.a(this.d, DataFixTypes.CHUNK, nbttagcompound1, k, 1493); -@@ -86,13 +121,29 @@ +@@ -86,13 +125,29 @@ } @@ -107,7 +111,7 @@ Chunk chunk = this.a(generatoraccess, i, j, nbttagcompound); if (chunk != null) { -@@ -101,6 +152,9 @@ +@@ -101,6 +156,9 @@ } return chunk; @@ -117,7 +121,7 @@ } } -@@ -132,7 +186,7 @@ +@@ -132,7 +190,7 @@ } @Nullable @@ -126,7 +130,7 @@ if (nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8)) { ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound); -@@ -151,10 +205,28 @@ +@@ -151,10 +209,28 @@ ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(chunk.locX), Integer.valueOf(chunk.locZ)); nbttagcompound1.setInt("xPos", i); nbttagcompound1.setInt("zPos", j); @@ -156,7 +160,7 @@ } } } else { -@@ -169,7 +241,7 @@ +@@ -169,7 +245,7 @@ ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound); if (chunkstatus_type == ChunkStatus.Type.LEVELCHUNK) { @@ -165,7 +169,7 @@ } else { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Level"); -@@ -217,10 +289,14 @@ +@@ -217,10 +293,14 @@ } public boolean a() { @@ -182,7 +186,7 @@ ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.c.getName()); } -@@ -236,10 +312,14 @@ +@@ -236,10 +316,14 @@ return true; } else { try { @@ -198,7 +202,7 @@ if (this.e != null) { this.e.a(chunkcoordintpair.a()); } -@@ -266,15 +346,16 @@ +@@ -266,15 +350,16 @@ public void b() { try { @@ -218,7 +222,7 @@ } } -@@ -303,7 +384,7 @@ +@@ -303,7 +388,7 @@ if (abiomebase != null) { for (int k = 0; k < abiomebase.length; ++k) { @@ -227,7 +231,7 @@ } } -@@ -385,7 +466,7 @@ +@@ -385,7 +470,7 @@ int[] aint = new int[abiomebase.length]; for (int i = 0; i < abiomebase.length; ++i) { @@ -236,7 +240,7 @@ } nbttagcompound.setIntArray("Biomes", aint); -@@ -487,27 +568,27 @@ +@@ -487,27 +572,27 @@ } ChunkConverter chunkconverter = nbttagcompound.hasKeyOfType("UpgradeData", 10) ? new ChunkConverter(nbttagcompound.getCompound("UpgradeData")) : ChunkConverter.a; @@ -270,7 +274,7 @@ long i1 = nbttagcompound.getLong("InhabitedTime"); Chunk chunk = new Chunk(generatoraccess.getMinecraftWorld(), i, j, abiomebase, chunkconverter, protochunkticklist, protochunkticklist1, i1); -@@ -850,17 +931,29 @@ +@@ -850,17 +935,29 @@ } @Nullable @@ -302,7 +306,7 @@ }); } -@@ -874,8 +967,14 @@ +@@ -874,8 +971,14 @@ } } @@ -318,7 +322,7 @@ Iterator iterator = entity.bP().iterator(); while (iterator.hasNext()) { -@@ -891,7 +990,7 @@ +@@ -891,7 +994,7 @@ boolean flag = false; try { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index adf232ea..ddaeefb7 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -146,6 +146,11 @@ public class CraftWorld implements World { return world.getChunkProviderServer().isLoaded(x, z); } + @Override + public boolean isChunkGenerated(int x, int z) { + return isChunkLoaded(x, z) || ((ChunkRegionLoader) world.getChunkProviderServer().chunkLoader).chunkExists(x, z); + } + public Chunk[] getLoadedChunks() { Object[] chunks = world.getChunkProviderServer().chunks.values().toArray(); org.bukkit.Chunk[] craftChunks = new CraftChunk[chunks.length]; |