Added an anti-cheat compatibility setting, to tie in with free look
This commit is contained in:
parent
dbb5d56b74
commit
2d7b465844
@ -222,6 +222,14 @@ public class Settings {
|
|||||||
*/
|
*/
|
||||||
public Setting<Boolean> freeLook = new Setting<>(true);
|
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
|
* Exclusively use cached chunks for pathing
|
||||||
*/
|
*/
|
||||||
|
@ -58,21 +58,42 @@ public class LookBehavior extends Behavior {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerUpdate(PlayerUpdateEvent event) {
|
public void onPlayerUpdate(PlayerUpdateEvent event) {
|
||||||
if (event.getState() == EventState.PRE && this.target != null && this.force) {
|
if (this.target == null)
|
||||||
player().rotationYaw = this.target.getFirst();
|
return;
|
||||||
float oldPitch = player().rotationPitch;
|
|
||||||
float desiredPitch = this.target.getSecond();
|
// Whether or not we're going to silently set our angles
|
||||||
player().rotationPitch = desiredPitch;
|
boolean silent = Baritone.settings().antiCheatCompatibility.get();
|
||||||
if (desiredPitch == oldPitch) {
|
|
||||||
nudgeToLevel();
|
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
|
@Override
|
||||||
public void onPlayerRelativeMove(RelativeMoveEvent event) {
|
public void onPlayerRelativeMove(RelativeMoveEvent event) {
|
||||||
if (this.target != null && !force) {
|
if (this.target != null && !this.force) {
|
||||||
switch (event.getState()) {
|
switch (event.getState()) {
|
||||||
case PRE:
|
case PRE:
|
||||||
this.lastYaw = player().rotationYaw;
|
this.lastYaw = player().rotationYaw;
|
||||||
@ -80,7 +101,10 @@ public class LookBehavior extends Behavior {
|
|||||||
break;
|
break;
|
||||||
case POST:
|
case POST:
|
||||||
player().rotationYaw = this.lastYaw;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user