mirror of
https://github.com/cabaletta/baritone
synced 2025-02-17 04:17:28 +00:00
Add smoothLook
setting
This commit is contained in:
parent
1902e6c1f3
commit
9d1addd114
@ -58,6 +58,7 @@ public final class Settings {
|
||||
public final Setting<Boolean> renderHitboxRaytraces = new Setting<>(false);
|
||||
public final Setting<Boolean> renderElytraSimulation = new Setting<>(false);
|
||||
public final Setting<Boolean> elytraFreeLook = new Setting<>(false);
|
||||
public final Setting<Boolean> smoothLook = new Setting<>(false);
|
||||
|
||||
// Experimental Elytra Settings
|
||||
public final Setting<Boolean> experimentalTakeoff = new Setting<>(false);
|
||||
|
@ -26,6 +26,7 @@ import baritone.api.event.events.*;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import baritone.api.utils.Rotation;
|
||||
import baritone.behavior.look.ForkableRandom;
|
||||
import com.google.common.collect.EvictingQueue;
|
||||
import net.minecraft.network.play.client.CPacketPlayer;
|
||||
|
||||
import java.util.Optional;
|
||||
@ -51,9 +52,12 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
|
||||
|
||||
private final AimProcessor processor;
|
||||
|
||||
private final EvictingQueue<Float> smoothYawBuffer;
|
||||
|
||||
public LookBehavior(Baritone baritone) {
|
||||
super(baritone);
|
||||
this.processor = new AimProcessor(baritone.getPlayerContext());
|
||||
this.smoothYawBuffer = EvictingQueue.create(10);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -96,8 +100,14 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
|
||||
case POST: {
|
||||
// Reset the player's rotations back to their original values
|
||||
if (this.prevRotation != null) {
|
||||
ctx.player().rotationYaw = this.prevRotation.getYaw();
|
||||
ctx.player().rotationPitch = this.prevRotation.getPitch();
|
||||
if (Baritone.settings().smoothLook.value) {
|
||||
ctx.player().rotationYaw = (float) this.smoothYawBuffer.stream()
|
||||
.mapToDouble(d -> d).average().orElseGet(this.prevRotation::getYaw);
|
||||
ctx.player().rotationPitch = this.prevRotation.getPitch();
|
||||
} else {
|
||||
ctx.player().rotationYaw = this.prevRotation.getYaw();
|
||||
ctx.player().rotationPitch = this.prevRotation.getPitch();
|
||||
}
|
||||
this.prevRotation = null;
|
||||
}
|
||||
// The target is done being used for this game tick, so it can be invalidated
|
||||
|
Loading…
Reference in New Issue
Block a user