diff --git a/leaf-server/minecraft-patches/features/0178-Asynchronous-locator.patch b/leaf-server/minecraft-patches/features/0178-Asynchronous-locator.patch index 687248d6..7ec2a2dd 100644 --- a/leaf-server/minecraft-patches/features/0178-Asynchronous-locator.patch +++ b/leaf-server/minecraft-patches/features/0178-Asynchronous-locator.patch @@ -7,43 +7,39 @@ Original license: MIT Original project: https://github.com/thebrightspark/AsyncLocator diff --git a/net/minecraft/server/commands/LocateCommand.java b/net/minecraft/server/commands/LocateCommand.java -index 2723d5377567241921fef61952e474c1c0ee9bbf..0918b528e0310b12378e185b29a478ed188a2d58 100644 +index 2723d5377567241921fef61952e474c1c0ee9bbf..548a33b857aef542279255368031a095037b76bb 100644 --- a/net/minecraft/server/commands/LocateCommand.java +++ b/net/minecraft/server/commands/LocateCommand.java -@@ -109,6 +109,38 @@ public class LocateCommand { +@@ -109,6 +109,34 @@ public class LocateCommand { BlockPos blockPos = BlockPos.containing(source.getPosition()); ServerLevel level = source.getLevel(); Stopwatch stopwatch = Stopwatch.createStarted(Util.TICKER); + // Leaf start - Asynchronous locator + if (org.dreeam.leaf.config.modules.async.AsyncLocator.enabled) { -+ net.minecraft.commands.CommandSource locatorSource = source.source; -+ if (locatorSource instanceof net.minecraft.server.level.ServerPlayer || locatorSource instanceof net.minecraft.server.MinecraftServer) { -+ BlockPos originPos = BlockPos.containing(source.getPosition()); ++ BlockPos originPos = BlockPos.containing(source.getPosition()); ++ org.dreeam.leaf.async.locate.AsyncLocator.locate(source.getLevel(), holderSet, originPos, 100, false) ++ .thenOnServerThread(pair -> { ++ stopwatch.stop(); ++ if (pair != null) { ++ showLocateResult( ++ source, ++ structure, ++ originPos, ++ pair, ++ "commands.locate.structure.success", ++ false, ++ stopwatch.elapsed() ++ ); ++ } else { ++ source.sendFailure( ++ Component.literal( ++ ERROR_STRUCTURE_NOT_FOUND.create(structure.asPrintable()).getMessage() ++ ) ++ ); ++ } ++ }); + -+ org.dreeam.leaf.async.locate.AsyncLocator.locate(source.getLevel(), holderSet, originPos, 100, false) -+ .thenOnServerThread(pair -> { -+ stopwatch.stop(); -+ if (pair != null) { -+ showLocateResult( -+ source, -+ structure, -+ originPos, -+ pair, -+ "commands.locate.structure.success", -+ false, -+ stopwatch.elapsed() -+ ); -+ } else { -+ source.sendFailure( -+ Component.literal( -+ ERROR_STRUCTURE_NOT_FOUND.create(structure.asPrintable()).getMessage() -+ ) -+ ); -+ } -+ }); -+ -+ return 0; -+ } ++ return 0; + } + // Leaf end - Asynchronous locator Pair> pair = level.getChunkSource().getGenerator().findNearestMapStructure(level, holderSet, blockPos, 100, false);