Smooth look, improve thisway command, and add logging to MineProcess

This commit is contained in:
0xf8 2023-06-08 14:59:50 -04:00
parent 2b6c59fa8a
commit c9b204ef31
Signed by: 0xf8
GPG Key ID: 446580D758689584
5 changed files with 45 additions and 18 deletions

View File

@ -1058,6 +1058,11 @@ public final class Settings {
*/
public final Setting<Boolean> legitMine = new Setting<>(false);
/**
* The increment that lookTo() will use when smoothly looking
*/
public final Setting<Float> lookToIncrement = new Setting<>(8.5f);
/**
* What Y level to go to for legit strip mining
*/

View File

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

View File

@ -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<String> 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 <distance> - makes a GoalXZ distance blocks in front of you"

View File

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

View File

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