home and sethome, fixes #54

This commit is contained in:
Leijurv 2018-08-22 17:49:55 -07:00
parent dab70926e2
commit 4bf1c79830
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -21,6 +21,8 @@ import baritone.Baritone;
import baritone.Settings;
import baritone.behavior.Behavior;
import baritone.behavior.impl.PathingBehavior;
import baritone.chunk.Waypoint;
import baritone.chunk.WorldProvider;
import baritone.event.events.ChatEvent;
import baritone.pathing.calc.AStarPathFinder;
import baritone.pathing.goals.Goal;
@ -122,6 +124,24 @@ public class ExampleBaritoneControl extends Behavior {
event.cancel();
return;
}
if (msg.toLowerCase().equals("sethome")) {
WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint("", Waypoint.Tag.HOME, playerFeet()));
displayChatMessageRaw("Saved. Say home to set goal.");
event.cancel();
return;
}
if (msg.toLowerCase().equals("home")) {
Waypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(Waypoint.Tag.HOME);
if (waypoint == null) {
displayChatMessageRaw("home not saved");
} else {
Goal goal = new GoalBlock(waypoint.location);
PathingBehavior.INSTANCE.setGoal(goal);
displayChatMessageRaw("Set goal to " + goal);
}
event.cancel();
return;
}
if (msg.toLowerCase().equals("costs")) {
Movement[] movements = AStarPathFinder.getConnectedPositions(new BetterBlockPos(playerFeet()), new CalculationContext());
ArrayList<Movement> moves = new ArrayList<>(Arrays.asList(movements));