@@ -63,8 +63,6 @@ public static CompletableFuture<Void> executePathfinding(BotConnection bot, Goal
6363 var dataManager = bot .dataManager ();
6464 var clientEntity = dataManager .clientEntity ();
6565
66- var pathCompletionFuture = new CompletableFuture <Void >();
67-
6866 Boolean2ObjectFunction <List <WorldAction >> findPath =
6967 requiresRepositioning -> {
7068 var level = dataManager .currentLevel ()
@@ -80,21 +78,14 @@ public static CompletableFuture<Void> executePathfinding(BotConnection bot, Goal
8078 logger .info ("Starting calculations at: {}" , start .formatXYZ ());
8179 var actionsFuture = routeFinder .findRouteFuture (NodeState .forInfo (start , inventory ), requiresRepositioning );
8280 bot .shutdownHooks ().add (() -> actionsFuture .cancel (true ));
83- while (!actionsFuture .isDone ()) {
84- if (pathCompletionFuture .isDone ()) {
85- actionsFuture .cancel (true );
86- return List .of ();
87- }
88-
89- TimeUtil .waitTime (1 , TimeUnit .MILLISECONDS );
90- }
91-
9281 var actions = actionsFuture .join ();
9382 logger .info ("Calculated path with {} actions: {}" , actions .size (), actions );
9483
9584 return actions ;
9685 };
9786
87+ var pathCompletionFuture = new CompletableFuture <Void >();
88+
9889 // Cancel the path if the bot is disconnected
9990 bot .shutdownHooks ().add (() -> pathCompletionFuture .cancel (true ));
10091
0 commit comments