]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Fix footsteps for players whose collision box min y != 0 (#12110)
authorGregor Parzefall <82708541+grorp@users.noreply.github.com>
Mon, 14 Mar 2022 20:01:18 +0000 (21:01 +0100)
committerGitHub <noreply@github.com>
Mon, 14 Mar 2022 20:01:18 +0000 (21:01 +0100)
src/client/localplayer.cpp

index 4f1ea7bda843b42e09b997a2b926f496c96d2b74..279efafe936265a7021ed1d224f068c9dff1fd2d 100644 (file)
@@ -672,19 +672,21 @@ v3s16 LocalPlayer::getStandingNodePos()
 
 v3s16 LocalPlayer::getFootstepNodePos()
 {
+       v3f feet_pos = getPosition() + v3f(0.0f, m_collisionbox.MinEdge.Y, 0.0f);
+
        // Emit swimming sound if the player is in liquid
        if (in_liquid_stable)
-               return floatToInt(getPosition(), BS);
+               return floatToInt(feet_pos, BS);
 
        // BS * 0.05 below the player's feet ensures a 1/16th height
        // nodebox is detected instead of the node below it.
        if (touching_ground)
-               return floatToInt(getPosition() - v3f(0.0f, BS * 0.05f, 0.0f), BS);
+               return floatToInt(feet_pos - v3f(0.0f, BS * 0.05f, 0.0f), BS);
 
        // A larger distance below is necessary for a footstep sound
        // when landing after a jump or fall. BS * 0.5 ensures water
        // sounds when swimming in 1 node deep water.
-       return floatToInt(getPosition() - v3f(0.0f, BS * 0.5f, 0.0f), BS);
+       return floatToInt(feet_pos - v3f(0.0f, BS * 0.5f, 0.0f), BS);
 }
 
 v3s16 LocalPlayer::getLightPosition() const