From e5f0d0f5dc168970945ec98cb2df853a2047fb72 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sat, 2 Mar 2019 15:45:42 -0800 Subject: [PATCH] Fix World#getChunkAtAsync(Location) variants incorectly calculating chunk x The blockX needs to be floored before converted to int, as float -> integer operations are truncation. (i.e -0.5 -> 0, we want -0.5 -> -1) --- Spigot-API-Patches/0135-Async-Chunks-API.patch | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Spigot-API-Patches/0135-Async-Chunks-API.patch b/Spigot-API-Patches/0135-Async-Chunks-API.patch index 361634ac32..389a08c945 100644 --- a/Spigot-API-Patches/0135-Async-Chunks-API.patch +++ b/Spigot-API-Patches/0135-Async-Chunks-API.patch @@ -1,4 +1,4 @@ -From 6dc478f219217b81d31c62ff433aaac40052ed7b Mon Sep 17 00:00:00 2001 +From c56c68eed04866793c411e6dc5eeeabe2f73ace1 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 29 Feb 2016 17:43:33 -0600 Subject: [PATCH] Async Chunks API @@ -8,7 +8,7 @@ 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 807bd7fc..61f2cd9a 100644 +index 807bd7fc..51cf7fd3 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java @@ -152,6 +152,352 @@ public interface World extends PluginMessageRecipient, Metadatable { @@ -175,7 +175,7 @@ index 807bd7fc..61f2cd9a 100644 + * will be executed synchronously + */ + public default void getChunkAtAsync(Location loc, java.util.function.Consumer cb) { -+ getChunkAtAsync((int)loc.getX() >> 4, (int)Math.floor(loc.getZ()) >> 4, true, cb); ++ getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, true, cb); + } + + /** @@ -197,7 +197,7 @@ index 807bd7fc..61f2cd9a 100644 + * will be executed synchronously + */ + public default void getChunkAtAsync(Location loc, boolean gen, java.util.function.Consumer cb) { -+ getChunkAtAsync((int)loc.getX() >> 4, (int)Math.floor(loc.getZ()) >> 4, gen, cb); ++ getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, gen, cb); + } + + /** @@ -259,7 +259,7 @@ index 807bd7fc..61f2cd9a 100644 + * @return Future that will resolve when the chunk is loaded + */ + public default java.util.concurrent.CompletableFuture getChunkAtAsync(Location loc) { -+ return getChunkAtAsync((int)loc.getX() >> 4, (int)Math.floor(loc.getZ()) >> 4, true); ++ return getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, true); + } + + /** @@ -279,7 +279,7 @@ index 807bd7fc..61f2cd9a 100644 + * @return Future that will resolve when the chunk is loaded + */ + public default java.util.concurrent.CompletableFuture getChunkAtAsync(Location loc, boolean gen) { -+ return getChunkAtAsync((int)loc.getX() >> 4, (int)Math.floor(loc.getZ()) >> 4, gen); ++ return getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, gen); + } + + /** @@ -398,5 +398,5 @@ index 2dd7a03c..59787c47 100644 * Returns a list of entities within a bounding box centered around this * entity -- -2.20.1 +2.21.0