From 4591895e492e5ab1d86040a50db25d786e135d70 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 16 Aug 2018 16:51:43 -0700 Subject: [PATCH] clear goal option. fixes #22 --- .../java/baritone/bot/behavior/impl/PathingBehavior.java | 7 ++++--- .../java/baritone/bot/utils/ExampleBaritoneControl.java | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/bot/behavior/impl/PathingBehavior.java b/src/main/java/baritone/bot/behavior/impl/PathingBehavior.java index f69b94e3..4598677a 100644 --- a/src/main/java/baritone/bot/behavior/impl/PathingBehavior.java +++ b/src/main/java/baritone/bot/behavior/impl/PathingBehavior.java @@ -65,7 +65,7 @@ public class PathingBehavior extends Behavior { synchronized (pathPlanLock) { if (current.failed() || current.finished()) { current = null; - if (goal.isInGoal(playerFeet())) { + if (goal == null || goal.isInGoal(playerFeet())) { displayChatMessageRaw("All done. At " + goal); next = null; return; @@ -118,7 +118,7 @@ public class PathingBehavior extends Behavior { // and we have no plan for what to do next return; } - if (goal.isInGoal(current.getPath().getDest())) { + if (goal == null || goal.isInGoal(current.getPath().getDest())) { // and this path dosen't get us all the way there return; } @@ -205,7 +205,7 @@ public class PathingBehavior extends Behavior { } }); if (talkAboutIt && current != null && current.getPath() != null) { - if (goal.isInGoal(current.getPath().getDest())) { + if (goal == null || goal.isInGoal(current.getPath().getDest())) { displayChatMessageRaw("Finished finding a path from " + start + " to " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered"); } else { displayChatMessageRaw("Found path segment from " + start + " towards " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered"); @@ -233,6 +233,7 @@ public class PathingBehavior extends Behavior { IPathFinder pf = new AStarPathFinder(start, goal, previous.map(IPath::positions)); return pf.calculate(); } catch (Exception e) { + displayChatMessageRaw("Exception: " + e); e.printStackTrace(); return Optional.empty(); } diff --git a/src/main/java/baritone/bot/utils/ExampleBaritoneControl.java b/src/main/java/baritone/bot/utils/ExampleBaritoneControl.java index aaf59b05..ca385646 100644 --- a/src/main/java/baritone/bot/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/bot/utils/ExampleBaritoneControl.java @@ -60,7 +60,11 @@ public class ExampleBaritoneControl extends Behavior { goal = new GoalBlock(playerFeet()); break; case 1: - goal = new GoalYLevel(Integer.parseInt(params[0])); + if (params[0].equals("clear") || params[0].equals("none")) { + goal = null; + } else { + goal = new GoalYLevel(Integer.parseInt(params[0])); + } break; case 2: goal = new GoalXZ(Integer.parseInt(params[0]), Integer.parseInt(params[1]));