9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-api/paper-patches/features/0018-Async-structure-locate-api.patch
Dreeam 3af60cbe46 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@de410d13 Fix reobf mappings regression in GameRules.Type (#12437)
PaperMC/Paper@33e8928f Add support for bonus chest configuration in WorldCreator (#12344)
PaperMC/Paper@723b511f Clone exit location passed to teleport event (#12354)
PaperMC/Paper@ed322043 Clone blockpos in InsideBlockEffectApplier record
PaperMC/Paper@6b4ad082 Add PlayerRespawnEvent#isMissingRespawnBlock (#12422)
PaperMC/Paper@c0bd5688 Add logic for Human canUseEquipmentSlot (#12433)
2025-04-14 21:30:21 -04:00

76 lines
4.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
Date: Mon, 1 Nov 2077 00:00:00 +0800
Subject: [PATCH] Async structure locate api
This patch depends on Asynchronous locator patch.
Added some asynchronous structure locate methods in World,
requires async-locator to be enabled in Leaf config, or else it will fall back to sync methods.
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index d0c2ff65893c1fd3903633ebc24aae879dc91f10..000ed0527609690b01a32053557b74049beed73c 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -4084,6 +4084,60 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
@Nullable
StructureSearchResult locateNearestStructure(@NotNull Location origin, @NotNull Structure structure, int radius, boolean findUnexplored);
+ // Leaf start - Async structure locate api
+ /**
+ * Find the closest nearby structure of a given {@link StructureType} asynchronously.
+ * <p>
+ * The {@code radius} is not a rigid square radius. Each structure may alter
+ * how many chunks to check for each iteration. Do not assume that only a
+ * radius x radius chunk area will be checked. For example,
+ * {@link StructureType#WOODLAND_MANSION} can potentially check up to 20,000
+ * blocks away (or more) regardless of the radius used.
+ * <p>
+ * This will <i>not</i> load or generate chunks.
+ * <p>
+ * The difference between searching for a {@link StructureType} and a
+ * {@link Structure} is, that a {@link StructureType} can refer to multiple
+ * {@link Structure Structures} while searching for a {@link Structure}
+ * while only search for the given {@link Structure}.
+ *
+ * @param origin where to start looking for a structure
+ * @param structureType the type of structure to find
+ * @param radius the radius, in chunks, around which to search
+ * @param findUnexplored true to only find unexplored structures
+ * @param afterComplete the action to perform once the search is complete.
+ * @see #locateNearestStructureAsync(Location, Structure, int, boolean, Consumer)
+ */
+ @org.jetbrains.annotations.ApiStatus.Experimental
+ void locateNearestStructureAsync(@NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored, @NotNull Consumer<@Nullable StructureSearchResult> afterComplete);
+
+ /**
+ * Find the closest nearby structure of a given {@link Structure} asynchronously.
+ * <p>
+ * The {@code radius} is not a rigid square radius. Each structure may alter
+ * how many chunks to check for each iteration. Do not assume that only a
+ * radius x radius chunk area will be checked. For example,
+ * {@link Structure#MANSION} can potentially check up to 20,000 blocks away
+ * (or more) regardless of the radius used.
+ * <p>
+ * This will <i>not</i> load or generate chunks.
+ * <p>
+ * The difference between searching for a {@link StructureType} and a
+ * {@link Structure} is, that a {@link StructureType} can refer to multiple
+ * {@link Structure Structures} while searching for a {@link Structure}
+ * while only search for the given {@link Structure}.
+ *
+ * @param origin where to start looking for a structure
+ * @param structure the structure to find
+ * @param radius the radius, in chunks, around which to search
+ * @param findUnexplored true to only find unexplored structures
+ * @param afterComplete the action to perform on server thread once the search is complete.
+ * @see #locateNearestStructureAsync(Location, StructureType, int, boolean, Consumer)
+ */
+ @org.jetbrains.annotations.ApiStatus.Experimental
+ void locateNearestStructureAsync(@NotNull Location origin, @NotNull Structure structure, int radius, boolean findUnexplored, @NotNull Consumer<@Nullable StructureSearchResult> afterComplete);
+ // Leaf end - Async structure locate api
+
// Paper start
/**
* Locates the nearest biome based on an origin, biome type, and radius to search.