diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index f4fd7db14..a835ed73f 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -247,7 +247,9 @@ public class Settings { public Setting movementTimeoutTicks = new Setting<>(100); /** - * Pathing ends after this amount of time, if a path has been found + * Pathing ends after this amount of time, but only if a path has been found + *

+ * If no valid path (length above the minimum) has been found, pathing continues up until the failure timeout */ public Setting primaryTimeoutMS = new Setting<>(500L); @@ -257,7 +259,9 @@ public class Settings { public Setting failureTimeoutMS = new Setting<>(2000L); /** - * Planning ahead while executing a segment ends after this amount of time, if a path has been found + * Planning ahead while executing a segment ends after this amount of time, but only if a path has been found + *

+ * If no valid path (length above the minimum) has been found, pathing continues up until the failure timeout */ public Setting planAheadPrimaryTimeoutMS = new Setting<>(4000L); diff --git a/src/api/java/baritone/api/pathing/goals/GoalComposite.java b/src/api/java/baritone/api/pathing/goals/GoalComposite.java index 2926b8528..415f74e56 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalComposite.java +++ b/src/api/java/baritone/api/pathing/goals/GoalComposite.java @@ -17,10 +17,7 @@ package baritone.api.pathing.goals; -import net.minecraft.util.math.BlockPos; - import java.util.Arrays; -import java.util.Collection; /** * A composite of many goals, any one of which satisfies the composite. @@ -40,14 +37,6 @@ public class GoalComposite implements Goal { this.goals = goals; } - public GoalComposite(BlockPos... blocks) { - this(Arrays.asList(blocks)); - } - - public GoalComposite(Collection blocks) { - this(blocks.stream().map(GoalBlock::new).toArray(Goal[]::new)); - } - @Override public boolean isInGoal(int x, int y, int z) { for (Goal goal : goals) { diff --git a/src/api/java/baritone/api/pathing/goals/GoalGetToBlock.java b/src/api/java/baritone/api/pathing/goals/GoalGetToBlock.java index 959b6fcc6..c4856cdd6 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalGetToBlock.java +++ b/src/api/java/baritone/api/pathing/goals/GoalGetToBlock.java @@ -48,10 +48,7 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos { int xDiff = x - this.x; int yDiff = y - this.y; int zDiff = z - this.z; - if (yDiff < 0) { - yDiff++; - } - return Math.abs(xDiff) + Math.abs(yDiff) + Math.abs(zDiff) <= 1; + return Math.abs(xDiff) + Math.abs(yDiff < 0 ? yDiff + 1 : yDiff) + Math.abs(zDiff) <= 1; } @Override @@ -59,7 +56,7 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos { int xDiff = x - this.x; int yDiff = y - this.y; int zDiff = z - this.z; - return GoalBlock.calculate(xDiff, yDiff, zDiff); + return GoalBlock.calculate(xDiff, yDiff < 0 ? yDiff + 1 : yDiff, zDiff); } @Override diff --git a/src/api/java/baritone/api/pathing/goals/GoalTwoBlocks.java b/src/api/java/baritone/api/pathing/goals/GoalTwoBlocks.java index 4ed1bf5ee..b1dc07a1d 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalTwoBlocks.java +++ b/src/api/java/baritone/api/pathing/goals/GoalTwoBlocks.java @@ -63,10 +63,7 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos { int xDiff = x - this.x; int yDiff = y - this.y; int zDiff = z - this.z; - if (yDiff < 0) { - yDiff++; - } - return GoalBlock.calculate(xDiff, yDiff, zDiff); + return GoalBlock.calculate(xDiff, yDiff < 0 ? yDiff + 1 : yDiff, zDiff); } @Override diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 0627ebb4c..cd072bb6f 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -92,7 +92,8 @@ public final class ChunkPacker { for (int z = 0; z < 16; z++) { // @formatter:off - https://www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html + https: +//www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html // @formatter:on for (int x = 0; x < 16; x++) { for (int y = 255; y >= 0; y--) { @@ -124,7 +125,7 @@ public final class ChunkPacker { private static PathingBlockType getPathingBlockType(IBlockState state) { Block block = state.getBlock(); - if (block.equals(Blocks.WATER) && !MovementHelper.isFlowing(state)) { + if (block == Blocks.WATER && !MovementHelper.isFlowing(state)) { // only water source blocks are plausibly usable, flowing water should be avoid return PathingBlockType.WATER; } diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 6d9ad67ed..f2dcf4b19 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -88,7 +88,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { if (isFinished) { throw new IllegalStateException("Path Finder is currently in use, and cannot be reused!"); } - this.cancelRequested = false; + cancelRequested = false; try { IPath path = calculate0(primaryTimeout, failureTimeout).map(IPath::postProcess).orElse(null); isFinished = true; diff --git a/src/main/java/baritone/utils/pathing/SegmentedCalculator.java b/src/main/java/baritone/utils/pathing/SegmentedCalculator.java index a0b8e27c1..75dd0282a 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(); + } }); } }