mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
Remove dead instance checks in AsyncLocator
This commit is contained in:
@@ -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<BlockPos, Holder<Structure>> pair = level.getChunkSource().getGenerator().findNearestMapStructure(level, holderSet, blockPos, 100, false);
|
||||
|
||||
Reference in New Issue
Block a user