Smooth look, improve thisway command, and add logging to MineProcess
This commit is contained in:
parent
2b6c59fa8a
commit
c9b204ef31
@ -1058,6 +1058,11 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> legitMine = new Setting<>(false);
|
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
|
* 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.PlayerUpdateEvent;
|
||||||
import baritone.api.event.events.RotationMoveEvent;
|
import baritone.api.event.events.RotationMoveEvent;
|
||||||
import baritone.api.utils.Rotation;
|
import baritone.api.utils.Rotation;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public final class LookBehavior extends Behavior implements ILookBehavior {
|
public final class LookBehavior extends Behavior implements ILookBehavior {
|
||||||
|
|
||||||
@ -68,15 +69,13 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
|
|||||||
switch (event.getState()) {
|
switch (event.getState()) {
|
||||||
case PRE: {
|
case PRE: {
|
||||||
if (this.force) {
|
if (this.force) {
|
||||||
ctx.player().rotationYaw = this.target.getYaw();
|
|
||||||
float oldPitch = ctx.player().rotationPitch;
|
|
||||||
float desiredPitch = this.target.getPitch();
|
float desiredPitch = this.target.getPitch();
|
||||||
ctx.player().rotationPitch = desiredPitch;
|
float desiredYaw = this.target.getYaw();
|
||||||
ctx.player().rotationYaw += (Math.random() - 0.5) * Baritone.settings().randomLooking.value;
|
|
||||||
ctx.player().rotationPitch += (Math.random() - 0.5) * Baritone.settings().randomLooking.value;
|
if (!Baritone.settings().freeLook.value) {
|
||||||
if (desiredPitch == oldPitch && !Baritone.settings().freeLook.value) {
|
lookTo(desiredYaw, desiredPitch);
|
||||||
nudgeToLevel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.target = null;
|
this.target = null;
|
||||||
}
|
}
|
||||||
if (silent) {
|
if (silent) {
|
||||||
@ -117,14 +116,28 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void lookTo(float desiredYaw, float desiredPitch) {
|
||||||
* Nudges the player's pitch to a regular level. (Between {@code -20} and {@code 10}, increments are by {@code 1})
|
if (desiredPitch == ctx.player().rotationPitch) {
|
||||||
*/
|
desiredPitch = 0;
|
||||||
private void nudgeToLevel() {
|
}
|
||||||
if (ctx.player().rotationPitch < -20) {
|
|
||||||
ctx.player().rotationPitch++;
|
float dy = desiredYaw - ctx.player().rotationYaw;
|
||||||
} else if (ctx.player().rotationPitch > 10) {
|
float dp = desiredPitch - ctx.player().rotationPitch;
|
||||||
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.argument.IArgConsumer;
|
||||||
import baritone.api.command.exception.CommandException;
|
import baritone.api.command.exception.CommandException;
|
||||||
import baritone.api.pathing.goals.GoalXZ;
|
import baritone.api.pathing.goals.GoalXZ;
|
||||||
|
import baritone.api.process.ICustomGoalProcess;
|
||||||
|
import baritone.cache.WorldScanner;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -43,6 +45,10 @@ public class ThisWayCommand extends Command {
|
|||||||
);
|
);
|
||||||
baritone.getCustomGoalProcess().setGoal(goal);
|
baritone.getCustomGoalProcess().setGoal(goal);
|
||||||
logDirect(String.format("Goal: %s", goal));
|
logDirect(String.format("Goal: %s", goal));
|
||||||
|
|
||||||
|
WorldScanner.INSTANCE.repack(ctx);
|
||||||
|
baritone.getCustomGoalProcess().path();
|
||||||
|
logDirect("Now pathing");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -58,7 +64,7 @@ public class ThisWayCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getLongDesc() {
|
public List<String> getLongDesc() {
|
||||||
return Arrays.asList(
|
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:",
|
"Usage:",
|
||||||
"> thisway <distance> - makes a GoalXZ distance blocks in front of you"
|
"> 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;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
}
|
}
|
||||||
if (Baritone.settings().legitMine.value) {
|
if (Baritone.settings().legitMine.value) {
|
||||||
if (!addNearby()) {
|
if (!addNearby()) {
|
||||||
|
logDirect("Couldn't find " + filter + " with legitMine");
|
||||||
cancel();
|
cancel();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -139,6 +140,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
}
|
}
|
||||||
PathingCommand command = updateGoal();
|
PathingCommand command = updateGoal();
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
|
logDirect("No " + filter + " in range");
|
||||||
|
logDirect("Try " + Baritone.settings().prefix + "explore");
|
||||||
// none in range
|
// none in range
|
||||||
// maybe say something in chat? (ahem impact)
|
// maybe say something in chat? (ahem impact)
|
||||||
cancel();
|
cancel();
|
||||||
|
Loading…
Reference in New Issue
Block a user