Merge pull request #3990 from cabaletta/elytra-freelook

Merge `elytra-freelook` into `elytra`
This commit is contained in:
leijurv
2023-06-15 20:00:45 -07:00
committed by GitHub
7 changed files with 130 additions and 44 deletions

View File

@@ -256,17 +256,17 @@ public class Elytra extends Behavior implements Helper {
}
if (requireClear ? isClear(start, dest) : clearView(start, dest)) {
Rotation rot = RotationUtils.calcRotationFromVec3d(start, dest, ctx.playerRotations());
ctx.player().rotationYaw = rot.getYaw();
long a = System.currentTimeMillis();
Float pitch = solvePitch(dest.subtract(start), steps, relaxation == 2);
if (pitch == null) {
baritone.getLookBehavior().updateTarget(new Rotation(rot.getYaw(), ctx.playerRotations().getPitch()), false);
continue;
}
long b = System.currentTimeMillis();
ctx.player().rotationPitch = pitch;
System.out.println("Solved pitch in " + (b - a) + " total time " + (b - t));
goingTo = i;
goal = path.get(i).add(0, dy, 0);
baritone.getLookBehavior().updateTarget(new Rotation(rot.getYaw(), pitch), false);
return;
}
}

View File

@@ -56,7 +56,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
@Override
public void updateTarget(Rotation rotation, boolean blockInteract) {
this.target = new Target(rotation, blockInteract);
this.target = new Target(rotation, Target.Mode.resolve(ctx, blockInteract));
}
@Override
@@ -149,6 +149,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
public void onPlayerRotationMove(RotationMoveEvent event) {
if (this.target != null) {
event.setYaw(this.target.rotation.getYaw());
event.setPitch(this.target.rotation.getPitch());
}
}
@@ -185,9 +186,9 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
public final Rotation rotation;
public final Mode mode;
public Target(Rotation rotation, boolean blockInteract) {
public Target(Rotation rotation, Mode mode) {
this.rotation = rotation;
this.mode = Mode.resolve(blockInteract);
this.mode = mode;
}
enum Mode {
@@ -206,12 +207,16 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
*/
NONE;
static Mode resolve(boolean blockInteract) {
static Mode resolve(IPlayerContext ctx, boolean blockInteract) {
final Settings settings = Baritone.settings();
final boolean antiCheat = settings.antiCheatCompatibility.value;
final boolean blockFreeLook = settings.blockFreeLook.value;
final boolean freeLook = settings.freeLook.value;
if (ctx.player().isElytraFlying()) {
return settings.elytraFreeLook.value ? SERVER : CLIENT;
}
if (!freeLook && !blockFreeLook) return CLIENT;
if (!blockFreeLook && blockInteract) return CLIENT;