From 9c5274dde41a5bb546b2cb3f8040e6f4f01a744f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 23 Nov 2018 13:12:18 -0800 Subject: [PATCH] runnable conversion --- src/main/java/baritone/behavior/PathingBehavior.java | 5 +---- .../java/baritone/utils/pathing/SegmentedCalculator.java | 8 ++++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 26e8687c..42186b5b 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -40,10 +40,7 @@ import baritone.utils.PathRenderer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashSet; -import java.util.Optional; +import java.util.*; import java.util.concurrent.LinkedBlockingQueue; import java.util.stream.Collectors; diff --git a/src/main/java/baritone/utils/pathing/SegmentedCalculator.java b/src/main/java/baritone/utils/pathing/SegmentedCalculator.java index a0b8e27c..75dd0282 100644 --- a/src/main/java/baritone/utils/pathing/SegmentedCalculator.java +++ b/src/main/java/baritone/utils/pathing/SegmentedCalculator.java @@ -72,7 +72,7 @@ public class SegmentedCalculator { return search.calculate(Baritone.settings().primaryTimeoutMS.get(), Baritone.settings().failureTimeoutMS.get()); // use normal time settings, not the plan ahead settings, so as to not overwhelm the computer } - public static void calculateSegmentsThreaded(BetterBlockPos start, Goal goal, CalculationContext context, Consumer> onCompletion) { + public static void calculateSegmentsThreaded(BetterBlockPos start, Goal goal, CalculationContext context, Consumer onCompletion, Runnable onFailure) { Baritone.getExecutor().execute(() -> { Optional result; try { @@ -81,7 +81,11 @@ public class SegmentedCalculator { ex.printStackTrace(); result = Optional.empty(); } - onCompletion.accept(result); + if (result.isPresent()) { + onCompletion.accept(result.get()); + } else { + onFailure.run(); + } }); } }