runnable conversion
This commit is contained in:
parent
002c678b4a
commit
9c5274dde4
@ -40,10 +40,7 @@ import baritone.utils.PathRenderer;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.chunk.EmptyChunk;
|
import net.minecraft.world.chunk.EmptyChunk;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -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
|
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<Optional<IPath>> onCompletion) {
|
public static void calculateSegmentsThreaded(BetterBlockPos start, Goal goal, CalculationContext context, Consumer<IPath> onCompletion, Runnable onFailure) {
|
||||||
Baritone.getExecutor().execute(() -> {
|
Baritone.getExecutor().execute(() -> {
|
||||||
Optional<IPath> result;
|
Optional<IPath> result;
|
||||||
try {
|
try {
|
||||||
@ -81,7 +81,11 @@ public class SegmentedCalculator {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
result = Optional.empty();
|
result = Optional.empty();
|
||||||
}
|
}
|
||||||
onCompletion.accept(result);
|
if (result.isPresent()) {
|
||||||
|
onCompletion.accept(result.get());
|
||||||
|
} else {
|
||||||
|
onFailure.run();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user