follow offset distance and direction

This commit is contained in:
Leijurv 2018-09-17 10:36:39 -07:00
parent 583a5046ef
commit b3654492be
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
3 changed files with 26 additions and 2 deletions

View File

@ -358,6 +358,23 @@ public class Settings {
*/
public Setting<Boolean> internalMiningAirException = new Setting<>(true);
/**
* The actual GoalNear is set this distance away from the entity you're following
* <p>
* For example, set followOffsetDistance to 5 and followRadius to 0 to always stay precisely 5 blocks north of your follow target.
*/
public Setting<Double> followOffsetDistance = new Setting<>(0D);
/**
* The actual GoalNear is set in this direction from the entity you're following
*/
public Setting<Float> followOffsetDirection = new Setting<>(0F);
/**
* The radius (for the GoalNear) of how close to your target position you actually have to be
*/
public Setting<Integer> followRadius = new Setting<>(3);
public final Map<String, Setting<?>> byLowerName;
public final List<Setting<?>> allSettings;

View File

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

View File

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