From fcb947bedcb2fc0a1a24e91ee8a54c743cd6001c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 22 Aug 2018 17:56:08 -0700 Subject: [PATCH] bed --- src/main/java/baritone/chunk/Waypoint.java | 2 +- .../utils/ExampleBaritoneControl.java | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/baritone/chunk/Waypoint.java b/src/main/java/baritone/chunk/Waypoint.java index 495608ba..d834ee2c 100644 --- a/src/main/java/baritone/chunk/Waypoint.java +++ b/src/main/java/baritone/chunk/Waypoint.java @@ -62,7 +62,7 @@ public class Waypoint { } public enum Tag { - HOME, DEATH, USER; + HOME, DEATH, BED, USER; { map.put(name().toLowerCase(), this); diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index de1ced27..fae6a4d8 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -115,12 +115,19 @@ public class ExampleBaritoneControl extends Behavior { event.cancel(); return; } - if (msg.toLowerCase().equals("spawn")) { - BlockPos spawnPoint = player().getBedLocation(); - // for some reason the default spawnpoint is underground sometimes - Goal goal = new GoalXZ(spawnPoint.getX(), spawnPoint.getY()); - PathingBehavior.INSTANCE.setGoal(goal); - displayChatMessageRaw("Goal: " + goal); + if (msg.toLowerCase().equals("spawn") || msg.toLowerCase().equals("bed")) { + Waypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(Waypoint.Tag.BED); + if (waypoint == null) { + BlockPos spawnPoint = player().getBedLocation(); + // for some reason the default spawnpoint is underground sometimes + Goal goal = new GoalXZ(spawnPoint.getX(), spawnPoint.getZ()); + displayChatMessageRaw("spawn not saved, defaulting to world spawn. set goal to " + goal); + PathingBehavior.INSTANCE.setGoal(goal); + } else { + Goal goal = new GoalBlock(waypoint.location); + PathingBehavior.INSTANCE.setGoal(goal); + displayChatMessageRaw("Set goal to most recent bed " + goal); + } event.cancel(); return; } @@ -137,7 +144,7 @@ public class ExampleBaritoneControl extends Behavior { } else { Goal goal = new GoalBlock(waypoint.location); PathingBehavior.INSTANCE.setGoal(goal); - displayChatMessageRaw("Set goal to " + goal); + displayChatMessageRaw("Set goal to saved home " + goal); } event.cancel(); return;