From e705f9808b9e1432466376787896e4a1dca98ff6 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 1 Sep 2018 14:45:57 -0700 Subject: [PATCH] add force cancel --- .../java/baritone/pathing/calc/AbstractNodeCostSearch.java | 6 ++++++ src/main/java/baritone/utils/ExampleBaritoneControl.java | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index b8f13f1e..2894b989 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -17,6 +17,7 @@ package baritone.pathing.calc; +import baritone.behavior.impl.PathingBehavior; import baritone.pathing.goals.Goal; import baritone.pathing.path.IPath; import baritone.utils.pathing.BetterBlockPos; @@ -121,6 +122,11 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { return node; } + public static void forceCancel() { + PathingBehavior.INSTANCE.cancel(); + currentlyRunning = null; + } + @Override public Optional pathToMostRecentNodeConsidered() { return Optional.ofNullable(mostRecentConsidered).map(node -> new Path(startNode, node, 0)); diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 8b262f0a..e695ff49 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -28,6 +28,7 @@ import baritone.chunk.ChunkPacker; import baritone.chunk.Waypoint; import baritone.chunk.WorldProvider; import baritone.pathing.calc.AStarPathFinder; +import baritone.pathing.calc.AbstractNodeCostSearch; import baritone.pathing.goals.*; import baritone.pathing.movement.ActionCosts; import baritone.pathing.movement.CalculationContext; @@ -117,6 +118,12 @@ public class ExampleBaritoneControl extends Behavior { displayChatMessageRaw("ok canceled"); return; } + if (msg.toLowerCase().equals("forcecancel")) { + AbstractNodeCostSearch.forceCancel(); + event.cancel(); + displayChatMessageRaw("ok force canceled"); + return; + } if (msg.toLowerCase().equals("invert")) { Goal goal = PathingBehavior.INSTANCE.getGoal(); BlockPos runAwayFrom;