From 2d7b46584452b3cb776f8c75824470275af0f08d Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 22 Aug 2018 22:07:27 -0500 Subject: [PATCH] Added an anti-cheat compatibility setting, to tie in with free look --- src/main/java/baritone/Settings.java | 8 ++++ .../baritone/behavior/impl/LookBehavior.java | 44 ++++++++++++++----- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index 207703cb..f1ac0474 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -222,6 +222,14 @@ public class Settings { */ public Setting freeLook = new Setting<>(true); + /** + * Will cause some minor behavioral differences to ensure that Baritone works on anticheats. + *

+ * At the moment this will silently set the player's rotations when using freeLook so you're not sprinting in + * directions other than forward, which is picken up by more "advanced" anticheats like AAC, but not NCP. + */ + public Setting antiCheatCompatibility = new Setting<>(true); + /** * Exclusively use cached chunks for pathing */ diff --git a/src/main/java/baritone/behavior/impl/LookBehavior.java b/src/main/java/baritone/behavior/impl/LookBehavior.java index a531cd88..00ffce54 100644 --- a/src/main/java/baritone/behavior/impl/LookBehavior.java +++ b/src/main/java/baritone/behavior/impl/LookBehavior.java @@ -58,21 +58,42 @@ public class LookBehavior extends Behavior { @Override public void onPlayerUpdate(PlayerUpdateEvent event) { - if (event.getState() == EventState.PRE && this.target != null && this.force) { - player().rotationYaw = this.target.getFirst(); - float oldPitch = player().rotationPitch; - float desiredPitch = this.target.getSecond(); - player().rotationPitch = desiredPitch; - if (desiredPitch == oldPitch) { - nudgeToLevel(); + if (this.target == null) + return; + + // Whether or not we're going to silently set our angles + boolean silent = Baritone.settings().antiCheatCompatibility.get(); + + switch (event.getState()) { + case PRE: { + if (this.force) { + player().rotationYaw = this.target.getFirst(); + float oldPitch = player().rotationPitch; + float desiredPitch = this.target.getSecond(); + player().rotationPitch = desiredPitch; + if (desiredPitch == oldPitch) { + nudgeToLevel(); + } + this.target = null; + } else if (silent) { + this.lastYaw = player().rotationYaw; + player().rotationYaw = this.target.getFirst(); + } + break; + } + case POST: { + if (!this.force && silent) { + player().rotationYaw = this.lastYaw; + this.target = null; + } + break; } - this.target = null; } } @Override public void onPlayerRelativeMove(RelativeMoveEvent event) { - if (this.target != null && !force) { + if (this.target != null && !this.force) { switch (event.getState()) { case PRE: this.lastYaw = player().rotationYaw; @@ -80,7 +101,10 @@ public class LookBehavior extends Behavior { break; case POST: player().rotationYaw = this.lastYaw; - this.target = null; + + // If we have antiCheatCompatibility on, we're going to use the target value later in onPlayerUpdate() + if (!Baritone.settings().antiCheatCompatibility.get()) + this.target = null; break; } }