Clean up some bad Optional practices
This commit is contained in:
@@ -411,7 +411,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
||||
}
|
||||
|
||||
PathCalculationResult calcResult = pathfinder.calculate(timeout);
|
||||
Optional<IPath> path = calcResult.path;
|
||||
Optional<IPath> path = calcResult.getPath();
|
||||
if (Baritone.settings().cutoffAtLoadBoundary.get()) {
|
||||
path = path.map(p -> {
|
||||
IPath result = p.cutoffAtLoadedChunks(context.world());
|
||||
@@ -443,7 +443,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
||||
queuePathEvent(PathEvent.CALC_FINISHED_NOW_EXECUTING);
|
||||
current = executor.get();
|
||||
} else {
|
||||
if (calcResult.type != PathCalculationResult.Type.CANCELLATION && calcResult.type != PathCalculationResult.Type.EXCEPTION) {
|
||||
if (calcResult.getType() != PathCalculationResult.Type.CANCELLATION && calcResult.getType() != PathCalculationResult.Type.EXCEPTION) {
|
||||
// don't dispatch CALC_FAILED on cancellation
|
||||
queuePathEvent(PathEvent.CALC_FAILED);
|
||||
}
|
||||
|
||||
@@ -89,16 +89,15 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
|
||||
}
|
||||
this.cancelRequested = false;
|
||||
try {
|
||||
Optional<IPath> path = calculate0(timeout);
|
||||
path = path.map(IPath::postProcess);
|
||||
IPath path = calculate0(timeout).map(IPath::postProcess).orElse(null);
|
||||
isFinished = true;
|
||||
if (cancelRequested) {
|
||||
return new PathCalculationResult(PathCalculationResult.Type.CANCELLATION, path);
|
||||
}
|
||||
if (!path.isPresent()) {
|
||||
return new PathCalculationResult(PathCalculationResult.Type.FAILURE, path);
|
||||
if (path == null) {
|
||||
return new PathCalculationResult(PathCalculationResult.Type.FAILURE);
|
||||
}
|
||||
if (goal.isInGoal(path.get().getDest())) {
|
||||
if (goal.isInGoal(path.getDest())) {
|
||||
return new PathCalculationResult(PathCalculationResult.Type.SUCCESS_TO_GOAL, path);
|
||||
} else {
|
||||
return new PathCalculationResult(PathCalculationResult.Type.SUCCESS_SEGMENT, path);
|
||||
@@ -106,7 +105,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
|
||||
} catch (Exception e) {
|
||||
Helper.HELPER.logDebug("Pathing exception: " + e);
|
||||
e.printStackTrace();
|
||||
return new PathCalculationResult(PathCalculationResult.Type.EXCEPTION, Optional.empty());
|
||||
return new PathCalculationResult(PathCalculationResult.Type.EXCEPTION);
|
||||
} finally {
|
||||
// this is run regardless of what exception may or may not be raised by calculate0
|
||||
isFinished = true;
|
||||
|
||||
@@ -141,7 +141,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
// TODO shaft mode, mine 1x1 shafts to either side
|
||||
// TODO also, see if the GoalRunAway with maintain Y at 11 works even from the surface
|
||||
if (branchPointRunaway == null) {
|
||||
branchPointRunaway = new GoalRunAway(1, Optional.of(y), branchPoint) {
|
||||
branchPointRunaway = new GoalRunAway(1, y, branchPoint) {
|
||||
@Override
|
||||
public boolean isInGoal(int x, int y, int z) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user