Smooth look, improve thisway command, and add logging to MineProcess
This commit is contained in:
parent
2b6c59fa8a
commit
c9b204ef31
@ -738,7 +738,7 @@ public final class Settings {
|
||||
public final Setting<Boolean> blacklistClosestOnFailure = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* 😎 Render cached chunks as semitransparent. Doesn't work with OptiFine 😭 Rarely randomly crashes, see <a href="https://github.com/cabaletta/baritone/issues/327">this issue</a>.
|
||||
* 😎Render cached chunks as semitransparent. Doesn't work with OptiFine😭 Rarely randomly crashes, see <a href="https://github.com/cabaletta/baritone/issues/327">this issue</a>.
|
||||
* <p>
|
||||
* 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<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
|
||||
*/
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user