diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 9e3e6a38..44e471bf 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -738,7 +738,7 @@ public final class Settings { public final Setting blacklistClosestOnFailure = new Setting<>(true); /** - * 😎 Render cached chunks as semitransparent. Doesn't work with OptiFine 😭 Rarely randomly crashes, see this issue. + * 😎Render cached chunks as semitransparent. Doesn't work with OptiFine😭 Rarely randomly crashes, see this issue. *

* Can be very useful on servers with low render distance. After enabling, you may need to reload the world in order for it to have an effect * (e.g. disconnect and reconnect, enter then exit the nether, die and respawn, etc). This may literally kill your FPS and CPU because @@ -1058,6 +1058,11 @@ public final class Settings { */ public final Setting legitMine = new Setting<>(false); + /** + * The increment that lookTo() will use when smoothly looking + */ + public final Setting lookToIncrement = new Setting<>(8.5f); + /** * What Y level to go to for legit strip mining */ diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index 32e5c22f..7799b051 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -23,6 +23,7 @@ import baritone.api.behavior.ILookBehavior; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.RotationMoveEvent; import baritone.api.utils.Rotation; +import net.minecraft.util.math.MathHelper; public final class LookBehavior extends Behavior implements ILookBehavior { @@ -68,15 +69,13 @@ public final class LookBehavior extends Behavior implements ILookBehavior { switch (event.getState()) { case PRE: { if (this.force) { - ctx.player().rotationYaw = this.target.getYaw(); - float oldPitch = ctx.player().rotationPitch; float desiredPitch = this.target.getPitch(); - ctx.player().rotationPitch = desiredPitch; - ctx.player().rotationYaw += (Math.random() - 0.5) * Baritone.settings().randomLooking.value; - ctx.player().rotationPitch += (Math.random() - 0.5) * Baritone.settings().randomLooking.value; - if (desiredPitch == oldPitch && !Baritone.settings().freeLook.value) { - nudgeToLevel(); + float desiredYaw = this.target.getYaw(); + + if (!Baritone.settings().freeLook.value) { + lookTo(desiredYaw, desiredPitch); } + this.target = null; } if (silent) { @@ -117,14 +116,28 @@ public final class LookBehavior extends Behavior implements ILookBehavior { } } - /** - * Nudges the player's pitch to a regular level. (Between {@code -20} and {@code 10}, increments are by {@code 1}) - */ - private void nudgeToLevel() { - if (ctx.player().rotationPitch < -20) { - ctx.player().rotationPitch++; - } else if (ctx.player().rotationPitch > 10) { - ctx.player().rotationPitch--; + private void lookTo(float desiredYaw, float desiredPitch) { + if (desiredPitch == ctx.player().rotationPitch) { + desiredPitch = 0; } + + float dy = desiredYaw - ctx.player().rotationYaw; + float dp = desiredPitch - ctx.player().rotationPitch; + float inc = 6; // TODO: make this a setting + + if (dy > -inc && dy < inc) { + ctx.player().rotationYaw += dy; + } else { + ctx.player().rotationYaw += inc * MathHelper.clamp(dy, -1, 1); + } + + if (dp > -inc && dp < inc) { + ctx.player().rotationPitch += dp; + } else { + ctx.player().rotationPitch += inc * MathHelper.clamp(dp, -1, 1); + } + + ctx.player().rotationYaw += (Math.random() - 0.5) * Baritone.settings().randomLooking.value; + ctx.player().rotationPitch += (Math.random() - 0.5) * Baritone.settings().randomLooking.value; } } diff --git a/src/main/java/baritone/command/defaults/ThisWayCommand.java b/src/main/java/baritone/command/defaults/ThisWayCommand.java index 0c10bba3..b9ad995c 100644 --- a/src/main/java/baritone/command/defaults/ThisWayCommand.java +++ b/src/main/java/baritone/command/defaults/ThisWayCommand.java @@ -22,6 +22,8 @@ import baritone.api.command.Command; import baritone.api.command.argument.IArgConsumer; import baritone.api.command.exception.CommandException; import baritone.api.pathing.goals.GoalXZ; +import baritone.api.process.ICustomGoalProcess; +import baritone.cache.WorldScanner; import java.util.Arrays; import java.util.List; @@ -43,6 +45,10 @@ public class ThisWayCommand extends Command { ); baritone.getCustomGoalProcess().setGoal(goal); logDirect(String.format("Goal: %s", goal)); + + WorldScanner.INSTANCE.repack(ctx); + baritone.getCustomGoalProcess().path(); + logDirect("Now pathing"); } @Override @@ -58,7 +64,7 @@ public class ThisWayCommand extends Command { @Override public List getLongDesc() { return Arrays.asList( - "Creates a GoalXZ some amount of blocks in the direction you're currently looking", + "Creates a GoalXZ some amount of blocks in the direction you're currently looking then immediately starts pathing to it", "", "Usage:", "> thisway - makes a GoalXZ distance blocks in front of you" diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 575815ea..bd31d768 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -447,7 +447,7 @@ public interface MovementHelper extends ActionCosts, Helper { return isWater(up) ^ Baritone.settings().assumeWalkOnWater.value; } - if (MovementHelper.isLava(block) && !MovementHelper.isFlowing(x, y, z, state, bsi) && Baritone.settings().assumeWalkOnLava.value) { // if we get here it means that assumeWalkOnLava must be true, so put it last + if (MovementHelper.isLava(block) && Baritone.settings().assumeWalkOnLava.value) { // if we get here it means that assumeWalkOnLava must be true, so put it last return true; } diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 34f5c4c3..3b37f576 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -112,6 +112,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } if (Baritone.settings().legitMine.value) { if (!addNearby()) { + logDirect("Couldn't find " + filter + " with legitMine"); cancel(); return null; } @@ -139,6 +140,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } PathingCommand command = updateGoal(); if (command == null) { + logDirect("No " + filter + " in range"); + logDirect("Try " + Baritone.settings().prefix + "explore"); // none in range // maybe say something in chat? (ahem impact) cancel();