clear goal option. fixes #22

This commit is contained in:
Leijurv 2018-08-16 16:51:43 -07:00
parent e1c6006084
commit 4591895e49
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 9 additions and 4 deletions

View File

@ -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();
}

View File

@ -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]));