Paper/Spigot-Server-Patches/0300-Add-async-chunk-load-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

33 Zeilen
1.3 KiB
Diff

From 3787c26863d8c99bc691d42779ad2b414097f826 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 21 Jul 2018 16:55:04 -0400
Subject: [PATCH] Add async chunk load API
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index e4c4cdb980..c2aa3917bf 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -156,6 +156,18 @@ public class CraftWorld implements World {
}
}
+ // Paper start - Async chunk load API
+ @Override
+ public java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(final int x, final int z, final boolean gen) {
+ final ChunkProviderServer cps = this.world.getChunkProviderServer();
+ java.util.concurrent.CompletableFuture<Chunk> future = new java.util.concurrent.CompletableFuture<>();
+ net.minecraft.server.Chunk chunk = cps.getChunkAt(x, z, true, gen);
+ // TODO: Add back async variant
+ future.complete(chunk != null ? chunk.bukkitChunk : null);
+ return future;
+ }
+ // Paper end
+
public Chunk getChunkAt(int x, int z) {
return this.world.getChunkProviderServer().getChunkAt(x, z, true, true).bukkitChunk;
}
--
2.19.0