diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index d9c2ff40..a3fb2b4f 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -358,6 +358,23 @@ public class Settings { */ public Setting internalMiningAirException = new Setting<>(true); + /** + * The actual GoalNear is set this distance away from the entity you're following + *

+ * For example, set followOffsetDistance to 5 and followRadius to 0 to always stay precisely 5 blocks north of your follow target. + */ + public Setting followOffsetDistance = new Setting<>(0D); + + /** + * The actual GoalNear is set in this direction from the entity you're following + */ + public Setting followOffsetDirection = new Setting<>(0F); + + /** + * The radius (for the GoalNear) of how close to your target position you actually have to be + */ + public Setting followRadius = new Setting<>(3); + public final Map> byLowerName; public final List> allSettings; diff --git a/src/main/java/baritone/behavior/FollowBehavior.java b/src/main/java/baritone/behavior/FollowBehavior.java index 8eb51708..0dd9893d 100644 --- a/src/main/java/baritone/behavior/FollowBehavior.java +++ b/src/main/java/baritone/behavior/FollowBehavior.java @@ -17,9 +17,12 @@ package baritone.behavior; +import baritone.Baritone; import baritone.api.behavior.Behavior; import baritone.api.event.events.TickEvent; import baritone.pathing.goals.GoalNear; +import baritone.pathing.goals.GoalXZ; +import baritone.utils.Helper; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; @@ -28,7 +31,7 @@ import net.minecraft.util.math.BlockPos; * * @author leijurv */ -public final class FollowBehavior extends Behavior { +public final class FollowBehavior extends Behavior implements Helper { public static final FollowBehavior INSTANCE = new FollowBehavior(); @@ -45,7 +48,8 @@ public final class FollowBehavior extends Behavior { return; } // lol this is trashy but it works - PathingBehavior.INSTANCE.setGoal(new GoalNear(new BlockPos(following), 3)); + GoalXZ g = GoalXZ.fromDirection(following.getPositionVector(), Baritone.settings().followOffsetDirection.get(), Baritone.settings().followOffsetDistance.get()); + PathingBehavior.INSTANCE.setGoal(new GoalNear(new BlockPos(g.getX(), following.posY, g.getZ()), Baritone.settings().followRadius.get())); PathingBehavior.INSTANCE.path(); } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 98964315..016b44f5 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -400,6 +400,9 @@ public class ExampleBaritoneControl extends Behavior implements Helper { if (setting.value.getClass() == Double.class) { setting.value = Double.parseDouble(data[1]); } + if (setting.value.getClass() == Float.class) { + setting.value = Float.parseFloat(data[1]); + } } catch (NumberFormatException e) { logDirect("Unable to parse " + data[1]); event.cancel();