Paper/Spigot-Server-Patches/0022-Add-async-chunk-load-API.patch

41 lines
1.5 KiB
Diff
Raw Normal View History

2017-11-18 11:04:21 +08:00
From f647a0ac1262878131e46148d82bd16ec24a0d10 Mon Sep 17 00:00:00 2001
2016-03-01 07:09:49 +08:00
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Tue, 1 Mar 2016 23:19:01 -0600
2014-11-07 08:31:52 +08:00
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
2017-11-18 11:04:21 +08:00
index ef8165da4..01fc193db 100644
2014-11-07 08:31:52 +08:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
2017-11-18 11:04:21 +08:00
@@ -134,6 +134,26 @@ public class CraftWorld implements World {
2014-11-07 08:31:52 +08:00
}
}
2016-03-01 07:09:49 +08:00
+ // Paper start - Async chunk load API
2014-11-07 08:31:52 +08:00
+ public void getChunkAtAsync(final int x, final int z, final ChunkLoadCallback callback) {
2016-03-01 07:09:49 +08:00
+ final ChunkProviderServer cps = this.world.getChunkProviderServer();
2014-11-07 08:31:52 +08:00
+ cps.getChunkAt(x, z, new Runnable() {
+ @Override
+ public void run() {
+ callback.onLoad(cps.getChunkAt(x, z).bukkitChunk);
+ }
+ });
+ }
2016-03-01 07:09:49 +08:00
+
2014-11-07 08:31:52 +08:00
+ public void getChunkAtAsync(Block block, ChunkLoadCallback callback) {
+ getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, callback);
+ }
2016-03-01 07:09:49 +08:00
+
2014-11-07 08:31:52 +08:00
+ public void getChunkAtAsync(Location location, ChunkLoadCallback callback) {
+ getChunkAtAsync(location.getBlockX() >> 4, location.getBlockZ() >> 4, callback);
+ }
2016-03-01 07:09:49 +08:00
+ // Paper end
2014-11-07 08:31:52 +08:00
+
public Chunk getChunkAt(int x, int z) {
2016-05-12 10:07:46 +08:00
return this.world.getChunkProviderServer().getChunkAt(x, z).bukkitChunk;
2014-11-07 08:31:52 +08:00
}
--
2017-11-18 11:04:21 +08:00
2.15.0
2014-11-07 08:31:52 +08:00