invert goal to run away

This commit is contained in:
Leijurv 2018-08-25 15:09:47 -07:00
parent 342bb8616c
commit fdf11f9d76
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 26 additions and 0 deletions

View File

@ -176,6 +176,10 @@ public class PathingBehavior extends Behavior {
this.goal = goal;
}
public Goal getGoal() {
return goal;
}
public PathExecutor getCurrent() {
return current;
}

View File

@ -109,6 +109,28 @@ public class ExampleBaritoneControl extends Behavior {
displayChatMessageRaw("ok canceled");
return;
}
if (msg.toLowerCase().equals("invert")) {
Goal goal = PathingBehavior.INSTANCE.getGoal();
BlockPos runAwayFrom;
if (goal instanceof GoalXZ) {
runAwayFrom = new BlockPos(((GoalXZ) goal).getX(), 0, ((GoalXZ) goal).getZ());
} else if (goal instanceof GoalBlock) {
runAwayFrom = ((GoalBlock) goal).getGoalPos();
} else {
displayChatMessageRaw("Goal must be GoalXZ or GoalBlock to invert");
displayChatMessageRaw("Inverting goal of player feet");
runAwayFrom = playerFeet();
}
PathingBehavior.INSTANCE.setGoal(new GoalRunAway(1, runAwayFrom) {
@Override
public boolean isInGoal(BlockPos pos) {
return false;
}
});
PathingBehavior.INSTANCE.path();
event.cancel();
return;
}
if (msg.toLowerCase().equals("reloadall")) {
WorldProvider.INSTANCE.getCurrentWorld().cache.reloadAllFromDisk();
displayChatMessageRaw("ok");