add force cancel

This commit is contained in:
Leijurv 2018-09-01 14:45:57 -07:00
parent 8d46c36269
commit e705f9808b
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 13 additions and 0 deletions

View File

@ -17,6 +17,7 @@
package baritone.pathing.calc; package baritone.pathing.calc;
import baritone.behavior.impl.PathingBehavior;
import baritone.pathing.goals.Goal; import baritone.pathing.goals.Goal;
import baritone.pathing.path.IPath; import baritone.pathing.path.IPath;
import baritone.utils.pathing.BetterBlockPos; import baritone.utils.pathing.BetterBlockPos;
@ -121,6 +122,11 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
return node; return node;
} }
public static void forceCancel() {
PathingBehavior.INSTANCE.cancel();
currentlyRunning = null;
}
@Override @Override
public Optional<IPath> pathToMostRecentNodeConsidered() { public Optional<IPath> pathToMostRecentNodeConsidered() {
return Optional.ofNullable(mostRecentConsidered).map(node -> new Path(startNode, node, 0)); return Optional.ofNullable(mostRecentConsidered).map(node -> new Path(startNode, node, 0));

View File

@ -28,6 +28,7 @@ import baritone.chunk.ChunkPacker;
import baritone.chunk.Waypoint; import baritone.chunk.Waypoint;
import baritone.chunk.WorldProvider; import baritone.chunk.WorldProvider;
import baritone.pathing.calc.AStarPathFinder; import baritone.pathing.calc.AStarPathFinder;
import baritone.pathing.calc.AbstractNodeCostSearch;
import baritone.pathing.goals.*; import baritone.pathing.goals.*;
import baritone.pathing.movement.ActionCosts; import baritone.pathing.movement.ActionCosts;
import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.CalculationContext;
@ -117,6 +118,12 @@ public class ExampleBaritoneControl extends Behavior {
displayChatMessageRaw("ok canceled"); displayChatMessageRaw("ok canceled");
return; return;
} }
if (msg.toLowerCase().equals("forcecancel")) {
AbstractNodeCostSearch.forceCancel();
event.cancel();
displayChatMessageRaw("ok force canceled");
return;
}
if (msg.toLowerCase().equals("invert")) { if (msg.toLowerCase().equals("invert")) {
Goal goal = PathingBehavior.INSTANCE.getGoal(); Goal goal = PathingBehavior.INSTANCE.getGoal();
BlockPos runAwayFrom; BlockPos runAwayFrom;