Skip to content

Commit 349814b

Browse files
committed
extract the "voluntary speed" from dog rawDelta and use only it to update the walkanim
1 parent 2b9d2cf commit 349814b

File tree

1 file changed

+12
-6
lines changed
  • src/main/java/doggytalents/common/entity

1 file changed

+12
-6
lines changed

src/main/java/doggytalents/common/entity/Dog.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,12 +1120,18 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) {
11201120

11211121
@Override
11221122
public void calculateEntityAnimation(boolean ySpeed) {
1123-
float rawDeltaMove = (float) Mth.length(
1124-
this.getX() - this.xo,
1125-
0,
1126-
this.getZ() - this.zo
1127-
);
1128-
this.updateWalkAnimation(rawDeltaMove);
1123+
double dx = this.getX() - this.xo;
1124+
double dz = this.getZ() - this.zo;
1125+
float l_xz = (float) Mth.length(dx, dz);
1126+
1127+
float yrot = this.getYRot() * Mth.DEG_TO_RAD;
1128+
float look_x = -Mth.sin(yrot);
1129+
float look_z = Mth.cos(yrot);
1130+
1131+
float voluntary_spped = (float) (dx * look_x + dz * look_z);
1132+
voluntary_spped = Mth.clamp(voluntary_spped, 0, l_xz);
1133+
1134+
this.updateWalkAnimation(voluntary_spped);
11291135
}
11301136

11311137
@Override

0 commit comments

Comments
 (0)