Skip to content

Commit b6930aa

Browse files
committed
refactor dogbodyrotationcontrol
1 parent 6f0de5f commit b6930aa

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/main/java/doggytalents/common/entity/ai/nav/DogBodyRotationControl.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ public void clientTick() {
2727
this.rotateHeadIfNecessary();
2828
this.lastStableYHeadRot = this.dog.yHeadRot;
2929
this.headStableTime = 0;
30+
return;
31+
}
32+
if (Math.abs(this.dog.yHeadRot - this.lastStableYHeadRot) > HEAD_STABLE_ANGLE) {
33+
this.headStableTime = 0;
34+
this.lastStableYHeadRot = this.dog.yHeadRot;
35+
this.rotateBodyIfNecessary();
3036
} else {
31-
if (Math.abs(this.dog.yHeadRot - this.lastStableYHeadRot) > 15.0F) {
32-
this.headStableTime = 0;
33-
this.lastStableYHeadRot = this.dog.yHeadRot;
34-
this.rotateBodyIfNecessary();
35-
} else {
36-
++this.headStableTime;
37-
if (this.headStableTime > 10) {
38-
this.rotateHeadTowardsFront();
39-
}
37+
++this.headStableTime;
38+
if (this.headStableTime > DELAY_UNTIL_STARTING_TO_FACE_FORWARD) {
39+
this.rotateHeadTowardsFront();
4040
}
4141
}
4242
}
@@ -50,8 +50,8 @@ private void rotateHeadIfNecessary() {
5050
}
5151

5252
private void rotateHeadTowardsFront() {
53-
int i = this.headStableTime - 10;
54-
float f = Mth.clamp((float)i / 10.0F, 0.0F, 1.0F);
53+
int i = this.headStableTime - DELAY_UNTIL_STARTING_TO_FACE_FORWARD;
54+
float f = Mth.clamp((float)i / HOW_LONG_IT_TAKES_TO_FACE_FORWARD, 0.0F, 1.0F);
5555
float f1 = (float)this.dog.getMaxHeadYRot() * (1.0F - f);
5656
this.dog.yBodyRot = Mth.rotateIfNecessary(this.dog.yBodyRot, this.dog.yHeadRot, f1);
5757
}

0 commit comments

Comments
 (0)