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.
This commit is contained in:
parent
fd1bd5223a
commit
7438edc9a1
|
@ -1,92 +0,0 @@
|
|||
From 7ddb76e8301b2f48545ea48d9bd3f965b643054b Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 29 Feb 2016 17:43:33 -0600
|
||||
Subject: [PATCH] Add async chunk load API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index 5e6cb56a..dbbcfec9 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -137,6 +137,78 @@ public interface World extends PluginMessageRecipient, Metadatable {
|
||||
*/
|
||||
public Chunk getChunkAt(Block block);
|
||||
|
||||
+ /**
|
||||
+ * Used by {@link World#getChunkAtAsync(Location,ChunkLoadCallback)} methods
|
||||
+ * to request a {@link Chunk} to be loaded, with this callback receiving
|
||||
+ * the chunk when it is finished.
|
||||
+ *
|
||||
+ * This callback will be executed on synchronously on the main thread.
|
||||
+ *
|
||||
+ * Timing and order this callback is fired is intentionally not defined and
|
||||
+ * and subject to change.
|
||||
+ */
|
||||
+ public static interface ChunkLoadCallback {
|
||||
+ public void onLoad(Chunk chunk);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a {@link Chunk} to be loaded at the given coordinates
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The {@link ChunkLoadCallback} will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ *
|
||||
+ * @param x Chunk X-coordinate of the chunk - (world coordinate / 16)
|
||||
+ * @param z Chunk Z-coordinate of the chunk - (world coordinate / 16)
|
||||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public void getChunkAtAsync(int x, int z, ChunkLoadCallback cb);
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a {@link Chunk} to be loaded at the given {@link Location}
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The {@link ChunkLoadCallback} will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ *
|
||||
+ * @param location Location of the chunk
|
||||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public void getChunkAtAsync(Location location, ChunkLoadCallback cb);
|
||||
+
|
||||
+ /**
|
||||
+ * Requests {@link Chunk} to be loaded that contains the given {@link Block}
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The {@link ChunkLoadCallback} will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ *
|
||||
+ * @param block Block to get the containing chunk from
|
||||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public void getChunkAtAsync(Block block, ChunkLoadCallback cb);
|
||||
+
|
||||
/**
|
||||
* Checks if the specified {@link Chunk} is loaded
|
||||
*
|
||||
--
|
||||
2.19.0
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
From 3c76bffe535e420aed08fd34bb95d98aac839102 Mon Sep 17 00:00:00 2001
|
||||
From 7388904ff97bc9690a82713c6d2dde88ae1551bc Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 21 Jul 2018 01:51:05 -0500
|
||||
Subject: [PATCH] EnderDragon Events
|
||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] EnderDragon Events
|
|||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFireballHitEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFireballHitEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..ef2a8dab
|
||||
index 000000000..ef2a8dab9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFireballHitEvent.java
|
||||
@@ -0,0 +1,72 @@
|
||||
|
@ -84,7 +84,7 @@ index 00000000..ef2a8dab
|
|||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFlameEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFlameEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..d8c3ab33
|
||||
index 000000000..d8c3ab330
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFlameEvent.java
|
||||
@@ -0,0 +1,56 @@
|
||||
|
@ -146,7 +146,7 @@ index 00000000..d8c3ab33
|
|||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonShootFireballEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonShootFireballEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..aa70dda1
|
||||
index 000000000..aa70dda10
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonShootFireballEvent.java
|
||||
@@ -0,0 +1,56 @@
|
|
@ -1,4 +1,4 @@
|
|||
From ae56a3fc7ab54bb3acb88fb67a82f7265aee6204 Mon Sep 17 00:00:00 2001
|
||||
From e3f49113573e7c633b84682c11837436b0eb86c5 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 21 Jul 2018 03:10:50 -0500
|
||||
Subject: [PATCH] PlayerLaunchProjectileEvent
|
||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] PlayerLaunchProjectileEvent
|
|||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerLaunchProjectileEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerLaunchProjectileEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..d2b244a4
|
||||
index 000000000..d2b244a41
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerLaunchProjectileEvent.java
|
||||
@@ -0,0 +1,78 @@
|
|
@ -1,4 +1,4 @@
|
|||
From 87dfe3fa6543580dcbdcad9f3ea10049ad597d29 Mon Sep 17 00:00:00 2001
|
||||
From 38df31e7cde8343c5d9df88d292baf068a60b628 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 21 Jul 2018 01:59:53 -0500
|
||||
Subject: [PATCH] PlayerElytraBoostEvent
|
||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] PlayerElytraBoostEvent
|
|||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerElytraBoostEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerElytraBoostEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..cecb2182
|
||||
index 000000000..cecb2182c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerElytraBoostEvent.java
|
||||
@@ -0,0 +1,80 @@
|
|
@ -1,4 +1,4 @@
|
|||
From 4e0b2a8d9666020afc83f97bd3fcb0987fa3058e Mon Sep 17 00:00:00 2001
|
||||
From dc559042b4464ebcd414f6160768d15753e49a12 Mon Sep 17 00:00:00 2001
|
||||
From: Anthony MacAllister <anthonymmacallister@gmail.com>
|
||||
Date: Thu, 26 Jul 2018 15:28:53 -0400
|
||||
Subject: [PATCH] EntityTransformedEvent
|
||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] EntityTransformedEvent
|
|||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..d9e5cab9
|
||||
index 000000000..d9e5cab95
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java
|
||||
@@ -0,0 +1,85 @@
|
|
@ -1,11 +1,11 @@
|
|||
From e0d00c017e6e25327d7fbabc1db99678b593a565 Mon Sep 17 00:00:00 2001
|
||||
From d1d6a6e701f0046fcae6f5a937d66e7b0698cdc5 Mon Sep 17 00:00:00 2001
|
||||
From: kashike <kashike@vq.lc>
|
||||
Date: Wed, 15 Aug 2018 01:26:03 -0700
|
||||
Subject: [PATCH] Allow disabling armour stand ticking
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/ArmorStand.java b/src/main/java/org/bukkit/entity/ArmorStand.java
|
||||
index 099da6ce..859f166f 100644
|
||||
index 099da6ce1..859f166fb 100644
|
||||
--- a/src/main/java/org/bukkit/entity/ArmorStand.java
|
||||
+++ b/src/main/java/org/bukkit/entity/ArmorStand.java
|
||||
@@ -275,5 +275,21 @@ public interface ArmorStand extends LivingEntity {
|
|
@ -1,4 +1,4 @@
|
|||
From 18b469ac5ad5d82fd19b75ec006a37e47936864d Mon Sep 17 00:00:00 2001
|
||||
From f7db1f306087584741afcbcc990658478a0c17b0 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Fri, 27 Jul 2018 22:36:17 -0500
|
||||
Subject: [PATCH] SkeletonHorse Additions
|
||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] SkeletonHorse Additions
|
|||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SkeletonHorseTrapEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SkeletonHorseTrapEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..55bae018
|
||||
index 000000000..55bae018e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SkeletonHorseTrapEvent.java
|
||||
@@ -0,0 +1,43 @@
|
||||
|
@ -54,7 +54,7 @@ index 00000000..55bae018
|
|||
+}
|
||||
+
|
||||
diff --git a/src/main/java/org/bukkit/entity/SkeletonHorse.java b/src/main/java/org/bukkit/entity/SkeletonHorse.java
|
||||
index b2c6b6a8..ba998346 100644
|
||||
index b2c6b6a86..ba9983463 100644
|
||||
--- a/src/main/java/org/bukkit/entity/SkeletonHorse.java
|
||||
+++ b/src/main/java/org/bukkit/entity/SkeletonHorse.java
|
||||
@@ -3,4 +3,12 @@ package org.bukkit.entity;
|
|
@ -1,4 +1,4 @@
|
|||
From b4f68b0722a75ef3075a8fd42c275522d448a71c Mon Sep 17 00:00:00 2001
|
||||
From a05d7aa6619f01679e452a714e900a5c14f4ffdc Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 25 Jul 2018 01:36:07 -0400
|
||||
Subject: [PATCH] Expand Location Manipulation API
|
||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] Expand Location Manipulation API
|
|||
Adds set(x, y, z), add(base, x, y, z), subtract(base, x, y, z);
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
|
||||
index 056a4d6b..8dcb15fb 100644
|
||||
index 056a4d6bb..8dcb15fb8 100644
|
||||
--- a/src/main/java/org/bukkit/Location.java
|
||||
+++ b/src/main/java/org/bukkit/Location.java
|
||||
@@ -503,6 +503,51 @@ public class Location implements Cloneable, ConfigurationSerializable {
|
|
@ -1,4 +1,4 @@
|
|||
From f58b6b90a61293cba3dae328d626b0b217afbbc7 Mon Sep 17 00:00:00 2001
|
||||
From a25458fced284f9f77b50f45aab28446751859de Mon Sep 17 00:00:00 2001
|
||||
From: willies952002 <admin@domnian.com>
|
||||
Date: Thu, 26 Jul 2018 02:22:44 -0400
|
||||
Subject: [PATCH] Expand ArmorStand API
|
||||
|
@ -8,7 +8,7 @@ Add the following:
|
|||
- Enable/Disable slot interactions
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/ArmorStand.java b/src/main/java/org/bukkit/entity/ArmorStand.java
|
||||
index 859f166f..eda4873d 100644
|
||||
index 859f166fb..eda4873d5 100644
|
||||
--- a/src/main/java/org/bukkit/entity/ArmorStand.java
|
||||
+++ b/src/main/java/org/bukkit/entity/ArmorStand.java
|
||||
@@ -1,5 +1,6 @@
|
|
@ -1,4 +1,4 @@
|
|||
From 848e7a6b6c7c5f5cf4d40f9a5566ca9e54da2246 Mon Sep 17 00:00:00 2001
|
||||
From b08e64c433d4014812d1c11d8ef43268f6804dcb Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Fri, 20 Jul 2018 23:36:55 -0500
|
||||
Subject: [PATCH] AnvilDamageEvent
|
||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] AnvilDamageEvent
|
|||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java b/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..fd3c5c02
|
||||
index 000000000..fd3c5c02e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java
|
||||
@@ -0,0 +1,139 @@
|
|
@ -1,4 +1,4 @@
|
|||
From b973baad7a6e6e970c515588e61ada683b1f67a8 Mon Sep 17 00:00:00 2001
|
||||
From 2c3530cf31446f0d52627710e8417518c98b3565 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 9 Sep 2018 00:32:05 -0400
|
||||
Subject: [PATCH] Remove deadlock risk in firing async events
|
||||
|
@ -16,7 +16,7 @@ which results in a hard crash.
|
|||
This change removes the synchronize and adds some protection around enable/disable
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
index cb2b0b9c..a7dd902f 100644
|
||||
index cb2b0b9cb..a7dd902fb 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
@@ -385,7 +385,7 @@ public final class SimplePluginManager implements PluginManager {
|
||||
|
@ -79,7 +79,7 @@ index cb2b0b9c..a7dd902f 100644
|
|||
RegisteredListener[] listeners = handlers.getRegisteredListeners();
|
||||
|
||||
diff --git a/src/test/java/org/bukkit/plugin/PluginManagerTest.java b/src/test/java/org/bukkit/plugin/PluginManagerTest.java
|
||||
index 6b86128e..56308c0c 100644
|
||||
index 6b86128e1..56308c0c6 100644
|
||||
--- a/src/test/java/org/bukkit/plugin/PluginManagerTest.java
|
||||
+++ b/src/test/java/org/bukkit/plugin/PluginManagerTest.java
|
||||
@@ -19,7 +19,7 @@ public class PluginManagerTest {
|
|
@ -1,11 +1,11 @@
|
|||
From 51ea14128492a66721efc64c903ed6ecd2e1ad64 Mon Sep 17 00:00:00 2001
|
||||
From 540ea528206d24ac317b8f88b0524917a54dc7ca Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Thu, 2 Aug 2018 08:44:20 -0500
|
||||
Subject: [PATCH] Add hand to bucket events
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java b/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java
|
||||
index 8fb121a9..7b9596f3 100644
|
||||
index 8fb121a91..7b9596f30 100644
|
||||
--- a/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java
|
||||
@@ -5,6 +5,7 @@ import org.bukkit.block.Block;
|
||||
|
@ -30,7 +30,7 @@ index 8fb121a9..7b9596f3 100644
|
|||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
diff --git a/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java b/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java
|
||||
index 56584687..3dbe428b 100644
|
||||
index 56584687f..3dbe428ba 100644
|
||||
--- a/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java
|
||||
@@ -5,6 +5,7 @@ import org.bukkit.block.Block;
|
||||
|
@ -82,7 +82,7 @@ index 56584687..3dbe428b 100644
|
|||
return cancelled;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java b/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java
|
||||
index 94e042a3..884b9240 100644
|
||||
index 94e042a36..884b9240b 100644
|
||||
--- a/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java
|
||||
@@ -5,6 +5,7 @@ import org.bukkit.block.Block;
|
|
@ -1,4 +1,4 @@
|
|||
From 156ee02d35570260db0ce2de98e8e4629f9240f4 Mon Sep 17 00:00:00 2001
|
||||
From 3d3caa8002d35ede44fd008d5b92ff4db850dfc6 Mon Sep 17 00:00:00 2001
|
||||
From: Mark Vainomaa <mikroskeem@mikroskeem.eu>
|
||||
Date: Sun, 15 Jul 2018 22:17:55 +0300
|
||||
Subject: [PATCH] Add TNTPrimeEvent
|
||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] Add TNTPrimeEvent
|
|||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/block/TNTPrimeEvent.java b/src/main/java/com/destroystokyo/paper/event/block/TNTPrimeEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..2ae8826b
|
||||
index 000000000..2ae8826bb
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/block/TNTPrimeEvent.java
|
||||
@@ -0,0 +1,108 @@
|
|
@ -1,4 +1,4 @@
|
|||
From 87ec4277ddff0dbc66ef9cd2d3b61696e301ea7b Mon Sep 17 00:00:00 2001
|
||||
From 9ec35d157059d4ecbd252758b13ffd7954976cbd Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 4 Aug 2018 19:37:35 -0400
|
||||
Subject: [PATCH] Provide Chunk Coordinates as a Long API
|
||||
|
@ -7,10 +7,10 @@ Allows you to easily access the chunks X/z as a long, and a method
|
|||
to look up by the long key too.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Chunk.java b/src/main/java/org/bukkit/Chunk.java
|
||||
index 079b9feb..c75bce07 100644
|
||||
index 079b9febe..b347a3ccf 100644
|
||||
--- a/src/main/java/org/bukkit/Chunk.java
|
||||
+++ b/src/main/java/org/bukkit/Chunk.java
|
||||
@@ -23,6 +23,15 @@ public interface Chunk {
|
||||
@@ -23,6 +23,32 @@ public interface Chunk {
|
||||
*/
|
||||
int getZ();
|
||||
|
||||
|
@ -19,7 +19,24 @@ index 079b9feb..c75bce07 100644
|
|||
+ * @return The Chunks X and Z coordinates packed into a long
|
||||
+ */
|
||||
+ default long getChunkKey() {
|
||||
+ return (long) getX() & 0xffffffffL | ((long) getZ() & 0xffffffffL) << 32;
|
||||
+ return getChunkKey(getX(), getZ());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @param loc Location to get chunk key
|
||||
+ * @return Location's chunk coordinates packed into a long
|
||||
+ */
|
||||
+ static long getChunkKey(Location loc) {
|
||||
+ return getChunkKey((int) Math.floor(loc.getX()) << 4, (int) Math.floor(loc.getZ()) << 4);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @param x X Coordinate
|
||||
+ * @param z Z Coordinate
|
||||
+ * @return Chunk coordinates packed into a long
|
||||
+ */
|
||||
+ static long getChunkKey(int x, int z) {
|
||||
+ return (long) x & 0xffffffffL | ((long) z & 0xffffffffL) << 32;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
|
@ -27,7 +44,7 @@ index 079b9feb..c75bce07 100644
|
|||
* Gets the world containing this chunk
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index dbbcfec9..724088ec 100644
|
||||
index 5e6cb56ab..e451ca611 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -137,6 +137,21 @@ public interface World extends PluginMessageRecipient, Metadatable {
|
||||
|
@ -50,8 +67,8 @@ index dbbcfec9..724088ec 100644
|
|||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Used by {@link World#getChunkAtAsync(Location,ChunkLoadCallback)} methods
|
||||
* to request a {@link Chunk} to be loaded, with this callback receiving
|
||||
* Checks if the specified {@link Chunk} is loaded
|
||||
*
|
||||
--
|
||||
2.19.0
|
||||
|
|
@ -0,0 +1,399 @@
|
|||
From b0f5de25bba0be7a410aeed8ba55df8e91f9ec6f Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 29 Feb 2016 17:43:33 -0600
|
||||
Subject: [PATCH] Async Chunks API
|
||||
|
||||
Adds API's to load or generate chunks asynchronously.
|
||||
|
||||
Also adds utility methods to Entity to teleport asynchronously.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index e451ca611..bf5c21814 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -150,6 +150,349 @@ public interface World extends PluginMessageRecipient, Metadatable {
|
||||
public default Chunk getChunkAt(long chunkKey) {
|
||||
return getChunkAt((int) chunkKey, (int) (chunkKey >> 32));
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * This is the Legacy API before Java 8 was supported. Java 8 Consumer is provided,
|
||||
+ * as well as future support
|
||||
+ *
|
||||
+ * Used by {@link World#getChunkAtAsync(Location,ChunkLoadCallback)} methods
|
||||
+ * to request a {@link Chunk} to be loaded, with this callback receiving
|
||||
+ * the chunk when it is finished.
|
||||
+ *
|
||||
+ * This callback will be executed on synchronously on the main thread.
|
||||
+ *
|
||||
+ * Timing and order this callback is fired is intentionally not defined and
|
||||
+ * and subject to change.
|
||||
+ *
|
||||
+ * @deprecated Use either the Future or the Consumer based methods
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ public static interface ChunkLoadCallback extends java.util.function.Consumer<Chunk> {
|
||||
+ public void onLoad(Chunk chunk);
|
||||
+
|
||||
+ // backwards compat to old api
|
||||
+ @Override
|
||||
+ default void accept(Chunk chunk) {
|
||||
+ onLoad(chunk);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a {@link Chunk} to be loaded at the given coordinates
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The {@link ChunkLoadCallback} will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ *
|
||||
+ * @deprecated Use either the Future or the Consumer based methods
|
||||
+ * @param x Chunk X-coordinate of the chunk - (world coordinate / 16)
|
||||
+ * @param z Chunk Z-coordinate of the chunk - (world coordinate / 16)
|
||||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ public default void getChunkAtAsync(int x, int z, ChunkLoadCallback cb) {
|
||||
+ getChunkAtAsync(x, z, true).thenAccept(cb::onLoad);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a {@link Chunk} to be loaded at the given {@link Location}
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The {@link ChunkLoadCallback} will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ *
|
||||
+ * @deprecated Use either the Future or the Consumer based methods
|
||||
+ * @param loc Location of the chunk
|
||||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ public default void getChunkAtAsync(Location loc, ChunkLoadCallback cb) {
|
||||
+ getChunkAtAsync(loc, true).thenAccept(cb::onLoad);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests {@link Chunk} to be loaded that contains the given {@link Block}
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The {@link ChunkLoadCallback} will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ *
|
||||
+ * @deprecated Use either the Future or the Consumer based methods
|
||||
+ * @param block Block to get the containing chunk from
|
||||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ public default void getChunkAtAsync(Block block, ChunkLoadCallback cb) {
|
||||
+ getChunkAtAsync(block, true).thenAccept(cb::onLoad);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a {@link Chunk} to be loaded at the given coordinates
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The {@link java.util.function.Consumer<Chunk>} will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ *
|
||||
+ * @param x Chunk X-coordinate of the chunk - (world coordinate / 16)
|
||||
+ * @param z Chunk Z-coordinate of the chunk - (world coordinate / 16)
|
||||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public default void getChunkAtAsync(int x, int z, java.util.function.Consumer<Chunk> cb) {
|
||||
+ getChunkAtAsync(x, z, true).thenAccept(cb);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a {@link Chunk} to be loaded at the given coordinates
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The {@link java.util.function.Consumer<Chunk>} will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ *
|
||||
+ * @param x Chunk X-coordinate of the chunk - (world coordinate / 16)
|
||||
+ * @param z Chunk Z-coordinate of the chunk - (world coordinate / 16)
|
||||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public default void getChunkAtAsync(int x, int z, boolean gen, java.util.function.Consumer<Chunk> cb) {
|
||||
+ getChunkAtAsync(x, z, gen).thenAccept(cb);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a {@link Chunk} to be loaded at the given {@link Location}
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The {@link java.util.function.Consumer<Chunk>} will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ *
|
||||
+ * @param loc Location of the chunk
|
||||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public default void getChunkAtAsync(Location loc, java.util.function.Consumer<Chunk> cb) {
|
||||
+ getChunkAtAsync((int)loc.getX() >> 4, (int)Math.floor(loc.getZ()) >> 4, true, cb);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a {@link Chunk} to be loaded at the given {@link Location}
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The {@link java.util.function.Consumer<Chunk>} will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ *
|
||||
+ * @param loc Location of the chunk
|
||||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public default void getChunkAtAsync(Location loc, boolean gen, java.util.function.Consumer<Chunk> cb) {
|
||||
+ getChunkAtAsync((int)loc.getX() >> 4, (int)Math.floor(loc.getZ()) >> 4, gen, cb);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests {@link Chunk} to be loaded that contains the given {@link Block}
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The {@link java.util.function.Consumer<Chunk>} will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ *
|
||||
+ * @param block Block to get the containing chunk from
|
||||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public default void getChunkAtAsync(Block block, java.util.function.Consumer<Chunk> cb) {
|
||||
+ getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, true, cb);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests {@link Chunk} to be loaded that contains the given {@link Block}
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The {@link java.util.function.Consumer<Chunk>} will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ *
|
||||
+ * @param block Block to get the containing chunk from
|
||||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public default void getChunkAtAsync(Block block, boolean gen, java.util.function.Consumer<Chunk> cb) {
|
||||
+ getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, gen, cb);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a {@link Chunk} to be loaded at the given coordinates
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The future will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ * @param loc Location to load the corresponding chunk from
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(Location loc) {
|
||||
+ return getChunkAtAsync((int)loc.getX() >> 4, (int)Math.floor(loc.getZ()) >> 4, true);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a {@link Chunk} to be loaded at the given coordinates
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The future will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ * @param loc Location to load the corresponding chunk from
|
||||
+ * @param gen Should the chunk generate
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(Location loc, boolean gen) {
|
||||
+ return getChunkAtAsync((int)loc.getX() >> 4, (int)Math.floor(loc.getZ()) >> 4, gen);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a {@link Chunk} to be loaded at the given coordinates
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The future will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ * @param block Block to load the corresponding chunk from
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(Block block) {
|
||||
+ return getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, true);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a {@link Chunk} to be loaded at the given coordinates
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The future will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ * @param block Block to load the corresponding chunk from
|
||||
+ * @param gen Should the chunk generate
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(Block block, boolean gen) {
|
||||
+ return getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, gen);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a {@link Chunk} to be loaded at the given coordinates
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The future will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ *
|
||||
+ * @param x X Coord
|
||||
+ * @param z Z Coord
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(int x, int z) {
|
||||
+ return getChunkAtAsync(x, z, true);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a {@link Chunk} to be loaded at the given coordinates
|
||||
+ *
|
||||
+ * This method makes no guarantee on how fast the chunk will load,
|
||||
+ * and will return the chunk to the callback at a later time.
|
||||
+ *
|
||||
+ * You should use this method if you need a chunk but do not need it
|
||||
+ * immediately, and you wish to let the server control the speed
|
||||
+ * of chunk loads, keeping performance in mind.
|
||||
+ *
|
||||
+ * The future will always be executed synchronously
|
||||
+ * on the main Server Thread.
|
||||
+ *
|
||||
+ * @param x Chunk X-coordinate of the chunk - (world coordinate / 16)
|
||||
+ * @param z Chunk Z-coordinate of the chunk - (world coordinate / 16)
|
||||
+ * @param gen Should we generate a chunk if it doesn't exists or not
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ public java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen);
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
||||
index 72ebe35fb..cd835edce 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||
@@ -124,6 +124,28 @@ public interface Entity extends Metadatable, CommandSender, Nameable {
|
||||
*/
|
||||
public boolean teleport(Entity destination, TeleportCause cause);
|
||||
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready.
|
||||
+ * @param loc Location to teleport to
|
||||
+ * @return A future that will be completed with the result of the teleport
|
||||
+ */
|
||||
+ public default java.util.concurrent.CompletableFuture<Boolean> teleportAsync(Location loc) {
|
||||
+ return teleportAsync(loc, TeleportCause.PLUGIN);
|
||||
+ }
|
||||
+ /**
|
||||
+ * Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready.
|
||||
+ * @param loc Location to teleport to
|
||||
+ * @param cause Reason for teleport
|
||||
+ * @return A future that will be completed with the result of the teleport
|
||||
+ */
|
||||
+ public default java.util.concurrent.CompletableFuture<Boolean> teleportAsync(Location loc, TeleportCause cause) {
|
||||
+ java.util.concurrent.CompletableFuture<Boolean> future = new java.util.concurrent.CompletableFuture<>();
|
||||
+ loc.getWorld().getChunkAtAsync(loc).thenAccept((chunk) -> future.complete(teleport(loc, cause)));
|
||||
+ return future;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Returns a list of entities within a bounding box centered around this
|
||||
* entity
|
||||
--
|
||||
2.19.0
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
From 90af86c318fc39b5cdd2e146ec045e8d51b1f0d6 Mon Sep 17 00:00:00 2001
|
||||
From 137d156f83cec3d2648e58d9701643131e773877 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 15 Aug 2018 01:04:58 -0400
|
||||
Subject: [PATCH] Ability to get Tile Entities from a chunk without snapshots
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Chunk.java b/src/main/java/org/bukkit/Chunk.java
|
||||
index c75bce07..dc847340 100644
|
||||
index b347a3ccf..8a8043351 100644
|
||||
--- a/src/main/java/org/bukkit/Chunk.java
|
||||
+++ b/src/main/java/org/bukkit/Chunk.java
|
||||
@@ -76,12 +76,24 @@ public interface Chunk {
|
||||
@@ -93,12 +93,24 @@ public interface Chunk {
|
||||
*/
|
||||
Entity[] getEntities();
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
From 5ea956be59a61bc48199bc7cd85518ec81f23aee Mon Sep 17 00:00:00 2001
|
||||
From d0f944db060ea8e9ffd782f139bc26ce8948b33f Mon Sep 17 00:00:00 2001
|
||||
From: cswhite2000 <18whitechristop@gmail.com>
|
||||
Date: Tue, 21 Aug 2018 19:39:46 -0700
|
||||
Subject: [PATCH] isChunkGenerated API
|
||||
|
||||
Resolves #1329
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
|
||||
index 7e1ee875..9457832b 100644
|
||||
index 7e1ee875e..9457832bc 100644
|
||||
--- a/src/main/java/org/bukkit/Location.java
|
||||
+++ b/src/main/java/org/bukkit/Location.java
|
||||
@@ -9,6 +9,7 @@ import org.bukkit.util.NumberConversions;
|
||||
|
@ -34,14 +33,13 @@ index 7e1ee875..9457832b 100644
|
|||
/**
|
||||
* Sets the position of this Location and returns itself
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index d4bfbad3..53764fae 100644
|
||||
index 348f1c98d..9c06fc163 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -181,6 +181,26 @@ public interface World extends PluginMessageRecipient, Metadatable {
|
||||
public default Chunk getChunkAt(long chunkKey) {
|
||||
@@ -182,6 +182,26 @@ public interface World extends PluginMessageRecipient, Metadatable {
|
||||
return getChunkAt((int) chunkKey, (int) (chunkKey >> 32));
|
||||
}
|
||||
+
|
||||
|
||||
+ /**
|
||||
+ * Checks if a {@link Chunk} has been generated at the specified chunk key,
|
||||
+ * which is the X and Z packed into a long.
|
||||
|
@ -61,9 +59,10 @@ index d4bfbad3..53764fae 100644
|
|||
+ * @return true if the chunk has been generated, otherwise false
|
||||
+ */
|
||||
+ public boolean isChunkGenerated(int x, int z);
|
||||
// Paper end
|
||||
|
||||
+
|
||||
/**
|
||||
* This is the Legacy API before Java 8 was supported. Java 8 Consumer is provided,
|
||||
* as well as future support
|
||||
--
|
||||
2.19.0
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
From 7fcd3fcb82c1622968faa0445f9408f78bae56d7 Mon Sep 17 00:00:00 2001
|
||||
From ed1936953435055091fc55bb268342ed8de59552 Mon Sep 17 00:00:00 2001
|
||||
From: willies952002 <admin@domnian.com>
|
||||
Date: Wed, 29 Aug 2018 00:37:30 -0400
|
||||
Subject: [PATCH] Add Force-Loaded Chunk API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Chunk.java b/src/main/java/org/bukkit/Chunk.java
|
||||
index dc847340..51bc051f 100644
|
||||
index 8a8043351..4b9e0ca46 100644
|
||||
--- a/src/main/java/org/bukkit/Chunk.java
|
||||
+++ b/src/main/java/org/bukkit/Chunk.java
|
||||
@@ -151,4 +151,20 @@ public interface Chunk {
|
||||
@@ -168,4 +168,20 @@ public interface Chunk {
|
||||
* @return true if slimes are able to spawn in this chunk
|
||||
*/
|
||||
boolean isSlimeChunk();
|
||||
|
@ -30,14 +30,13 @@ index dc847340..51bc051f 100644
|
|||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index 53764fae..00b02e36 100644
|
||||
index 9c06fc163..5379a649e 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -201,6 +201,16 @@ public interface World extends PluginMessageRecipient, Metadatable {
|
||||
* @return true if the chunk has been generated, otherwise false
|
||||
@@ -202,6 +202,16 @@ public interface World extends PluginMessageRecipient, Metadatable {
|
||||
*/
|
||||
public boolean isChunkGenerated(int x, int z);
|
||||
+
|
||||
|
||||
+ /**
|
||||
+ * Checks if a chunk is force-loaded.
|
||||
+ * Note: This will only return true if the chunk is also generated
|
||||
|
@ -47,9 +46,10 @@ index 53764fae..00b02e36 100644
|
|||
+ * @return true if the chunk is force-loaded. otherwise false
|
||||
+ */
|
||||
+ public boolean isChunkForceLoaded(int x, int z);
|
||||
// Paper end
|
||||
|
||||
+
|
||||
/**
|
||||
* This is the Legacy API before Java 8 was supported. Java 8 Consumer is provided,
|
||||
* as well as future support
|
||||
--
|
||||
2.19.0
|
||||
|
||||
|
|
|
@ -1,35 +1,26 @@
|
|||
From 1bd10f722ce808327480228cfa9924c43dd9e989 Mon Sep 17 00:00:00 2001
|
||||
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..af977b171a 100644
|
||||
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,27 @@ public class CraftWorld implements World {
|
||||
@@ -156,6 +156,18 @@ public class CraftWorld implements World {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start - Async chunk load API
|
||||
+ public void getChunkAtAsync(final int x, final int z, final ChunkLoadCallback callback) {
|
||||
+ @Override
|
||||
+ public java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(final int x, final int z, final boolean gen) {
|
||||
+ final ChunkProviderServer cps = this.world.getChunkProviderServer();
|
||||
+ callback.onLoad(cps.getChunkAt(x, z, true, true).bukkitChunk); // TODO: Add back async variant
|
||||
+ /*cps.getChunkAt(x, z, new Runnable() {
|
||||
+ @Override
|
||||
+ public void run() {
|
||||
+ callback.onLoad(cps.getChunkAt(x, z).bukkitChunk);
|
||||
+ }
|
||||
+ });*/
|
||||
+ }
|
||||
+
|
||||
+ public void getChunkAtAsync(Block block, ChunkLoadCallback callback) {
|
||||
+ getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, callback);
|
||||
+ }
|
||||
+
|
||||
+ public void getChunkAtAsync(Location location, ChunkLoadCallback callback) {
|
||||
+ getChunkAtAsync(location.getBlockX() >> 4, location.getBlockZ() >> 4, callback);
|
||||
+ 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
|
||||
+
|
||||
|
@ -37,5 +28,5 @@ index e4c4cdb980..af977b171a 100644
|
|||
return this.world.getChunkProviderServer().getChunkAt(x, z, true, true).bukkitChunk;
|
||||
}
|
||||
--
|
||||
2.18.0
|
||||
2.19.0
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From c21ec8930d87437aaf3ea6a85b09b599b0eb4589 Mon Sep 17 00:00:00 2001
|
||||
From 359e5d1b04b9e3e5f97e17d7bc778ab01bc5768e Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 28 Jul 2018 12:18:27 -0400
|
||||
Subject: [PATCH] Ignore Dead Entities in entityList iteration
|
||||
|
@ -71,10 +71,10 @@ index 597169b4cc..b18ea7154f 100644
|
|||
if (entity instanceof EntityInsentient) {
|
||||
EntityInsentient entityinsentient = (EntityInsentient) entity;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index af977b171a..80fd49b6e1 100644
|
||||
index c2aa3917bf..edf2e39e3d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -653,6 +653,7 @@ public class CraftWorld implements World {
|
||||
@@ -644,6 +644,7 @@ public class CraftWorld implements World {
|
||||
for (Object o : world.entityList) {
|
||||
if (o instanceof net.minecraft.server.Entity) {
|
||||
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o;
|
||||
|
@ -82,7 +82,7 @@ index af977b171a..80fd49b6e1 100644
|
|||
Entity bukkitEntity = mcEnt.getBukkitEntity();
|
||||
|
||||
// Assuming that bukkitEntity isn't null
|
||||
@@ -671,6 +672,7 @@ public class CraftWorld implements World {
|
||||
@@ -662,6 +663,7 @@ public class CraftWorld implements World {
|
||||
for (Object o : world.entityList) {
|
||||
if (o instanceof net.minecraft.server.Entity) {
|
||||
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o;
|
||||
|
@ -90,7 +90,7 @@ index af977b171a..80fd49b6e1 100644
|
|||
Entity bukkitEntity = mcEnt.getBukkitEntity();
|
||||
|
||||
// Assuming that bukkitEntity isn't null
|
||||
@@ -695,6 +697,7 @@ public class CraftWorld implements World {
|
||||
@@ -686,6 +688,7 @@ public class CraftWorld implements World {
|
||||
|
||||
for (Object entity: world.entityList) {
|
||||
if (entity instanceof net.minecraft.server.Entity) {
|
||||
|
@ -98,7 +98,7 @@ index af977b171a..80fd49b6e1 100644
|
|||
Entity bukkitEntity = ((net.minecraft.server.Entity) entity).getBukkitEntity();
|
||||
|
||||
if (bukkitEntity == null) {
|
||||
@@ -717,6 +720,7 @@ public class CraftWorld implements World {
|
||||
@@ -708,6 +711,7 @@ public class CraftWorld implements World {
|
||||
|
||||
for (Object entity: world.entityList) {
|
||||
if (entity instanceof net.minecraft.server.Entity) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From 8a7c8360a348229b1e81432124ea1093dc29bc70 Mon Sep 17 00:00:00 2001
|
||||
From 740216f5bc5bf37f2d525c217c986838b6c24559 Mon Sep 17 00:00:00 2001
|
||||
From: Mystiflow <mystiflow@gmail.com>
|
||||
Date: Fri, 6 Jul 2018 13:21:30 +0100
|
||||
Subject: [PATCH] Send nearby packets from world player list not server list
|
||||
|
@ -119,10 +119,10 @@ index 911d03c70b..f837e6c36c 100644
|
|||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 80fd49b6e1..ba2e768594 100644
|
||||
index edf2e39e3d..2611971575 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -1512,7 +1512,7 @@ public class CraftWorld implements World {
|
||||
@@ -1503,7 +1503,7 @@ public class CraftWorld implements World {
|
||||
double z = loc.getZ();
|
||||
|
||||
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), SoundCategory.valueOf(category.name()), new Vec3D(x, y, z), volume, pitch);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From c1aeede6736d16c3a1b61fee9caaf09e2fca2d5b Mon Sep 17 00:00:00 2001
|
||||
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
|
||||
|
@ -6,7 +6,7 @@ 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 0ca071b879..96d49b469a 100644
|
||||
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 {
|
||||
|
@ -20,10 +20,10 @@ index 0ca071b879..96d49b469a 100644
|
|||
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 ba2e768594..1ccf2a7609 100644
|
||||
index 2611971575..99d8199996 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -605,6 +605,12 @@ public class CraftWorld implements World {
|
||||
@@ -596,6 +596,12 @@ public class CraftWorld implements World {
|
||||
return getChunkAt(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
}
|
||||
|
||||
|
@ -37,5 +37,5 @@ index ba2e768594..1ccf2a7609 100644
|
|||
return generator;
|
||||
}
|
||||
--
|
||||
2.18.0
|
||||
2.19.0
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From a9234a415b098ba1ddf6cd3c67d7cd000521045c Mon Sep 17 00:00:00 2001
|
||||
From 7a5dbc00ebc5103326157c6a22529554e6fca3a6 Mon Sep 17 00:00:00 2001
|
||||
From: willies952002 <admin@domnian.com>
|
||||
Date: Wed, 29 Aug 2018 00:37:42 -0400
|
||||
Subject: [PATCH] Implement Force-Loaded Chunk API
|
||||
|
@ -40,10 +40,10 @@ index 12c6d850d2..55394e0c15 100644
|
|||
Arrays.fill(emptySkyLight, (byte) 0xFF);
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 1ccf2a7609..755d2632fd 100644
|
||||
index 99d8199996..f8ef782f14 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -609,6 +609,10 @@ public class CraftWorld implements World {
|
||||
@@ -600,6 +600,10 @@ public class CraftWorld implements World {
|
||||
public boolean isChunkGenerated(int x, int z) {
|
||||
return this.getHandle().getChunkProviderServer().isChunkGenerated(x, z);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From ef38ead333d3bdd03afea499031df21f298d5919 Mon Sep 17 00:00:00 2001
|
||||
From ff9abbb55e424ee806cd9bf8305ad13bd4e9135e Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 29 Aug 2018 21:59:22 -0400
|
||||
Subject: [PATCH] Optimize getChunkIfLoaded type calls
|
||||
|
@ -55,10 +55,10 @@ index 2ff8536d59..0c42d042b1 100644
|
|||
return chunk != null && !chunk.isEmpty();
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 755d2632fd..585a0c7fd2 100644
|
||||
index f8ef782f14..b411776c3c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -227,7 +227,7 @@ public class CraftWorld implements World {
|
||||
@@ -218,7 +218,7 @@ public class CraftWorld implements World {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ index 755d2632fd..585a0c7fd2 100644
|
|||
if (chunk != null) {
|
||||
world.getChunkProviderServer().unload(chunk);
|
||||
}
|
||||
@@ -246,7 +246,7 @@ public class CraftWorld implements World {
|
||||
@@ -237,7 +237,7 @@ public class CraftWorld implements World {
|
||||
|
||||
private boolean unloadChunk0(int x, int z, boolean save) {
|
||||
Boolean result = MCUtil.ensureMain("Unload Chunk", () -> { // Paper - Ensure never async
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From 420efcfbfe29045088fac0365c997a4ac120eca4 Mon Sep 17 00:00:00 2001
|
||||
From 69295bb452ceab708218850cfcad6d5b03d9a44b Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Sun, 2 Sep 2018 19:34:33 -0700
|
||||
Subject: [PATCH] Make CraftWorld#loadChunk(int, int, false) load unconverted
|
||||
|
@ -6,10 +6,10 @@ Subject: [PATCH] Make CraftWorld#loadChunk(int, int, false) load unconverted
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 585a0c7fd2..b38e394f83 100644
|
||||
index b411776c3c..262363999d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -304,7 +304,7 @@ public class CraftWorld implements World {
|
||||
@@ -295,7 +295,7 @@ public class CraftWorld implements World {
|
||||
public boolean loadChunk(int x, int z, boolean generate) {
|
||||
org.spigotmc.AsyncCatcher.catchOp( "chunk load"); // Spigot
|
||||
chunkLoadCount++;
|
||||
|
@ -19,5 +19,5 @@ index 585a0c7fd2..b38e394f83 100644
|
|||
|
||||
public boolean isChunkLoaded(Chunk chunk) {
|
||||
--
|
||||
2.18.0
|
||||
2.19.0
|
||||
|
||||
|
|
Loading…
Reference in New Issue