Added an anti-cheat compatibility setting, to tie in with free look

This commit is contained in:
Brady 2018-08-22 22:07:27 -05:00
parent dbb5d56b74
commit 2d7b465844
No known key found for this signature in database
GPG Key ID: 73A788379A197567
2 changed files with 42 additions and 10 deletions

View File

@ -222,6 +222,14 @@ public class Settings {
*/
public Setting<Boolean> freeLook = new Setting<>(true);
/**
* Will cause some minor behavioral differences to ensure that Baritone works on anticheats.
* <p>
* 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<Boolean> antiCheatCompatibility = new Setting<>(true);
/**
* Exclusively use cached chunks for pathing
*/

View File

@ -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;
}
}