Paper/Spigot-Server-Patches/0344-isChunkGenerated-API.patch
Aikar 7438edc9a1
Rework Async Chunks API in prep for merge, add utility
This adds a new Future based, Consumer<Chunk> based, and ability
to control whether or not to generate to the Async Chunk API.

Until Async Chunks merges, these API's are still synchronous, but
this commit will allow plugins to start using the API's in use
with the Async Chunks beta.
2018-09-21 16:56:08 -04:00

42 lines
1.8 KiB
Diff

From b89f3bcbeb09fca84b3891892ea7d6ca4e96b5d1 Mon Sep 17 00:00:00 2001
From: cswhite2000 <18whitechristop@gmail.com>
Date: Tue, 21 Aug 2018 19:44:10 -0700
Subject: [PATCH] isChunkGenerated API
Resolves #1329
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 60f249a031..fc621911e0 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -34,6 +34,9 @@ public class ChunkProviderServer implements IChunkProvider {
private long lastQueuedSaves = 0L; // Paper
private long lastProcessedSaves = 0L; // Paper
private long lastSaveStatPrinted = System.currentTimeMillis();
+ public boolean isChunkGenerated(int x, int z) {
+ return this.chunks.containsKey(ChunkCoordIntPair.asLong(x, z)) || ((ChunkRegionLoader) this.chunkLoader).chunkExists(x, z);
+ }
// Paper end
public final Long2ObjectMap<Chunk> chunks = Long2ObjectMaps.synchronize(new ChunkMap(8192));
private Chunk lastChunk;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 2611971575..99d8199996 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -596,6 +596,12 @@ public class CraftWorld implements World {
return getChunkAt(location.getBlockX() >> 4, location.getBlockZ() >> 4);
}
+ // Paper start
+ public boolean isChunkGenerated(int x, int z) {
+ return this.getHandle().getChunkProviderServer().isChunkGenerated(x, z);
+ }
+ // Paper end
+
public ChunkGenerator getGenerator() {
return generator;
}
--
2.19.0