From e293cbe631efde9a6795405a0146362f86d1549a Mon Sep 17 00:00:00 2001 From: kno10 Date: Sun, 27 Oct 2024 14:03:50 +0100 Subject: [PATCH] Better handling of touching_ground for bouncing on beds (#4689) Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4689 Reviewed-by: the-real-herowl Co-authored-by: kno10 Co-committed-by: kno10 --- mods/ENTITIES/mcl_mobs/physics.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 994c530f5..441156a1d 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -928,8 +928,6 @@ end -- falling and fall damage -- returns true if mob died function mob_class:falling(pos, moveresult) - if moveresult and moveresult.touching_ground then return false end - if self.fly and self.state ~= "die" then return end @@ -952,7 +950,13 @@ function mob_class:falling(pos, moveresult) new_acceleration = vector.new(0, DEFAULT_FALL_SPEED, 0) elseif v.y <= 0 and v.y > self.fall_speed then -- fall downwards at set speed - new_acceleration = vector.new(0, self.fall_speed, 0) + if moveresult and moveresult.touching_ground then + -- when touching ground, retain a minimal gravity to keep the touching_ground flag + -- but also to not get upwards acceleration with large dtime when on bouncy ground + new_acceleration = vector.new(0, self.fall_speed * 0.01, 0) + else + new_acceleration = vector.new(0, self.fall_speed, 0) + end else -- stop accelerating once max fall speed hit new_acceleration =vector.zero()