From 9dd5aa21b17cd9b844ed78cbe940423e18afdab0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 10 Aug 2018 10:45:13 -0700 Subject: [PATCH] nudge to level --- .../bot/behavior/impl/LookBehavior.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/bot/behavior/impl/LookBehavior.java b/src/main/java/baritone/bot/behavior/impl/LookBehavior.java index 952fed3b..016df45e 100644 --- a/src/main/java/baritone/bot/behavior/impl/LookBehavior.java +++ b/src/main/java/baritone/bot/behavior/impl/LookBehavior.java @@ -28,7 +28,7 @@ public class LookBehavior extends Behavior { /** * Target's values are as follows: - * + *

* getFirst() -> yaw * getSecond() -> pitch */ @@ -42,8 +42,21 @@ public class LookBehavior extends Behavior { public void onPlayerUpdate() { if (target != null) { player().rotationYaw = target.getFirst(); - player().rotationPitch = target.getSecond(); + float oldPitch = player().rotationPitch; + float desiredPitch = target.getSecond(); + player().rotationPitch = desiredPitch; + if (desiredPitch == oldPitch) { + nudgeToLevel(); + } target = null; } } + + private void nudgeToLevel() { + if (player().rotationPitch < -20) { + player().rotationPitch++; + } else if (player().rotationPitch > 10) { + player().rotationPitch--; + } + } }