From cae554bc2bfb74a0131d57781f5e48c20f6eb5cb Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Sun, 26 May 2024 15:32:41 +0000 Subject: [PATCH] Defensive checks (#4328) Fixes rare crashes related to some effects Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4328 Co-authored-by: the-real-herowl Co-committed-by: the-real-herowl --- mods/ITEMS/mcl_potions/functions.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 460a1cb8f..90ac35004 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -372,7 +372,9 @@ mcl_potions.register_effect({ playerphysics.add_physics_factor(object, "gravity", "mcl_potions:slow_falling", 0.5) end, on_step = function(dtime, object, factor, duration) - local vel = object:get_velocity().y + local vel = object:get_velocity() + if not vel then return end + vel = vel.y if vel < -3 then object:add_velocity(vector.new(0,-3-vel,0)) end end, on_end = function(object) @@ -430,7 +432,9 @@ mcl_potions.register_effect({ return S("moves body upwards at @1 nodes/s", factor) end, on_step = function(dtime, object, factor, duration) - local vel = object:get_velocity().y + local vel = object:get_velocity() + if not vel then return end + vel = vel.y if vel