Skip to content

Commit

Permalink
feat: 为Entity引入重力参数
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Aug 8, 2023
1 parent 632b37f commit 3361a4a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,8 @@ default boolean computeMovementServerSide() {
default double getStepHeight() {
return 0.6;
}

default double getGravity() {
return 0.08;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected void updateMotion(Entity entity) {
newMx = approachMx + 0.02 * Math.sin(yaw);
newMz = approachMz + 0.02 * Math.cos(yaw);
}
double newMy = (my - 0.08) * 0.98;
double newMy = (my - entity.getGravity()) * 0.98;
if (Math.abs(newMx) < MOTION_THRESHOLD) newMx = 0;
if (Math.abs(newMy) < MOTION_THRESHOLD) newMy = 0;
if (Math.abs(newMz) < MOTION_THRESHOLD) newMz = 0;
Expand Down

0 comments on commit 3361a4a

Please sign in to comment.