diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 012c257c..3b8108d8 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -147,7 +147,12 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { @Override public Optional pathToMostRecentNodeConsidered() { - return Optional.ofNullable(mostRecentConsidered).map(node -> new Path(startNode, node, 0, goal)); + try { + return Optional.ofNullable(mostRecentConsidered).map(node -> new Path(startNode, node, 0, goal)); + } catch (IllegalStateException ex) { + System.out.println("Unable to construct path to render"); + return Optional.empty(); + } } protected int mapSize() { @@ -164,7 +169,12 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { continue; } if (getDistFromStartSq(bestSoFar[i]) > MIN_DIST_PATH * MIN_DIST_PATH) { // square the comparison since distFromStartSq is squared - return Optional.of(new Path(startNode, bestSoFar[i], 0, goal)); + try { + return Optional.of(new Path(startNode, bestSoFar[i], 0, goal)); + } catch (IllegalStateException ex) { + System.out.println("Unable to construct path to render"); + return Optional.empty(); + } } } // instead of returning bestSoFar[0], be less misleading diff --git a/src/main/java/baritone/pathing/calc/Path.java b/src/main/java/baritone/pathing/calc/Path.java index 50dd49d7..c429970b 100644 --- a/src/main/java/baritone/pathing/calc/Path.java +++ b/src/main/java/baritone/pathing/calc/Path.java @@ -107,6 +107,7 @@ class Path implements IPath { return move; } } + // leave this as IllegalStateException; it's caught in AbstractNodeCostSearch throw new IllegalStateException("Movement became impossible during calculation " + src + " " + dest + " " + dest.subtract(src)); }