mirror of https://github.com/cabaletta/baritone
Do `nudgeToLevel` and `randomLooking` when using freeLook
This commit is contained in:
parent
1d5ee079b4
commit
c8a0ae9e10
|
@ -58,43 +58,37 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerUpdate(PlayerUpdateEvent event) {
|
public void onPlayerUpdate(PlayerUpdateEvent event) {
|
||||||
if (this.target == null) {
|
if (this.target == null || this.target.mode == Target.Mode.NONE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (event.getState()) {
|
switch (event.getState()) {
|
||||||
case PRE: {
|
case PRE: {
|
||||||
switch (this.target.mode) {
|
if (this.target.mode == Target.Mode.SERVER) {
|
||||||
case CLIENT: {
|
this.prevRotation = new Rotation(ctx.player().rotationYaw, ctx.player().rotationPitch);
|
||||||
ctx.player().rotationYaw = this.target.rotation.getYaw();
|
}
|
||||||
float oldPitch = ctx.player().rotationPitch;
|
|
||||||
float desiredPitch = this.target.rotation.getPitch();
|
ctx.player().rotationYaw = this.target.rotation.getYaw();
|
||||||
ctx.player().rotationPitch = desiredPitch;
|
float oldPitch = ctx.playerRotations().getPitch();
|
||||||
ctx.player().rotationYaw += (Math.random() - 0.5) * Baritone.settings().randomLooking.value;
|
float desiredPitch = this.target.rotation.getPitch();
|
||||||
ctx.player().rotationPitch += (Math.random() - 0.5) * Baritone.settings().randomLooking.value;
|
ctx.player().rotationPitch = desiredPitch;
|
||||||
if (desiredPitch == oldPitch && !Baritone.settings().freeLook.value) {
|
ctx.player().rotationYaw += (Math.random() - 0.5) * Baritone.settings().randomLooking.value;
|
||||||
nudgeToLevel();
|
ctx.player().rotationPitch += (Math.random() - 0.5) * Baritone.settings().randomLooking.value;
|
||||||
}
|
if (desiredPitch == oldPitch) {
|
||||||
// The target can be invalidated now since it won't be needed for RotationMoveEvent
|
nudgeToLevel();
|
||||||
this.target = null;
|
}
|
||||||
break;
|
|
||||||
}
|
if (this.target.mode == Target.Mode.CLIENT) {
|
||||||
case SERVER: {
|
// The target can be invalidated now since it won't be needed for RotationMoveEvent
|
||||||
// Copy the player's actual rotation
|
this.target = null;
|
||||||
this.prevRotation = new Rotation(ctx.player().rotationYaw, ctx.player().rotationPitch);
|
|
||||||
ctx.player().rotationYaw = this.target.rotation.getYaw();
|
|
||||||
ctx.player().rotationPitch = this.target.rotation.getPitch();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case POST: {
|
case POST: {
|
||||||
// Reset the player's rotations back to their original values
|
// Reset the player's rotations back to their original values
|
||||||
if (this.target.mode == Target.Mode.SERVER) {
|
if (this.prevRotation != null) {
|
||||||
ctx.player().rotationYaw = this.prevRotation.getYaw();
|
ctx.player().rotationYaw = this.prevRotation.getYaw();
|
||||||
ctx.player().rotationPitch = this.prevRotation.getPitch();
|
ctx.player().rotationPitch = this.prevRotation.getPitch();
|
||||||
|
this.prevRotation = null;
|
||||||
}
|
}
|
||||||
// The target is done being used for this game tick, so it can be invalidated
|
// The target is done being used for this game tick, so it can be invalidated
|
||||||
this.target = null;
|
this.target = null;
|
||||||
|
|
Loading…
Reference in New Issue