This commit is contained in:
Brady 2018-11-05 16:05:25 -06:00
parent f286c400a3
commit 0373f1875f
No known key found for this signature in database
GPG Key ID: 73A788379A197567
4 changed files with 16 additions and 13 deletions

View File

@ -24,14 +24,12 @@ package baritone.api.event.events.type;
public enum EventState { public enum EventState {
/** /**
* Indicates that whatever movement the event is being * Before the dispatching of what the event is targetting
* dispatched as a result of is about to occur.
*/ */
PRE, PRE,
/** /**
* Indicates that whatever movement the event is being * After the dispatching of what the event is targetting
* dispatched as a result of has already occurred.
*/ */
POST POST
} }

View File

@ -64,10 +64,10 @@ public class MixinEntity {
target = "net/minecraft/entity/Entity.rotationYaw:F" target = "net/minecraft/entity/Entity.rotationYaw:F"
) )
) )
private float overrideYaw(Entity entity) { private float overrideYaw(Entity self) {
if (entity instanceof EntityPlayerSP) { if (self instanceof EntityPlayerSP) {
return this.motionUpdateRotationEvent.getYaw(); return this.motionUpdateRotationEvent.getYaw();
} }
return entity.rotationYaw; return self.rotationYaw;
} }
} }

View File

@ -68,10 +68,10 @@ public abstract class MixinEntityLivingBase extends Entity {
target = "net/minecraft/entity/EntityLivingBase.rotationYaw:F" target = "net/minecraft/entity/EntityLivingBase.rotationYaw:F"
) )
) )
private float overrideYaw(EntityLivingBase entity) { private float overrideYaw(EntityLivingBase self) {
if (entity instanceof EntityPlayerSP) { if (self instanceof EntityPlayerSP) {
return this.jumpRotationEvent.getYaw(); return this.jumpRotationEvent.getYaw();
} }
return entity.rotationYaw; return self.rotationYaw;
} }
} }

View File

@ -26,6 +26,7 @@ import baritone.api.utils.Rotation;
import baritone.utils.Helper; import baritone.utils.Helper;
public final class LookBehavior extends Behavior implements ILookBehavior, Helper { public final class LookBehavior extends Behavior implements ILookBehavior, Helper {
/** /**
* Target's values are as follows: * Target's values are as follows:
* <p> * <p>
@ -63,7 +64,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior, Helpe
} }
// Whether or not we're going to silently set our angles // Whether or not we're going to silently set our angles
boolean silent = Baritone.settings().antiCheatCompatibility.get(); boolean silent = Baritone.settings().antiCheatCompatibility.get() && !this.force;
switch (event.getState()) { switch (event.getState()) {
case PRE: { case PRE: {
@ -76,14 +77,15 @@ public final class LookBehavior extends Behavior implements ILookBehavior, Helpe
nudgeToLevel(); nudgeToLevel();
} }
this.target = null; this.target = null;
} else if (silent) { }
if (silent) {
this.lastYaw = player().rotationYaw; this.lastYaw = player().rotationYaw;
player().rotationYaw = this.target.getYaw(); player().rotationYaw = this.target.getYaw();
} }
break; break;
} }
case POST: { case POST: {
if (!this.force && silent) { if (silent) {
player().rotationYaw = this.lastYaw; player().rotationYaw = this.lastYaw;
this.target = null; this.target = null;
} }
@ -108,6 +110,9 @@ public final class LookBehavior extends Behavior implements ILookBehavior, Helpe
} }
} }
/**
* Nudges the player's pitch to a regular level. (Between {@code -20} and {@code 10}, increments are by {@code 1})
*/
private void nudgeToLevel() { private void nudgeToLevel() {
if (player().rotationPitch < -20) { if (player().rotationPitch < -20) {
player().rotationPitch++; player().rotationPitch++;