From 28c0a3072c4cee48cd6d441ef5b9eae4ed16d850 Mon Sep 17 00:00:00 2001 From: kno10 Date: Tue, 31 Dec 2024 01:23:47 +0100 Subject: [PATCH] set_yaw for shulker returns nil, causing a nil arithmetic error. (#4775) Fixes a prevented crash error. Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4775 Reviewed-by: the-real-herowl Co-authored-by: kno10 Co-committed-by: kno10 --- mods/ENTITIES/mcl_mobs/physics.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 7db0e8166..99a4b1b10 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -240,11 +240,13 @@ end -- Relative turn, primarily for random turning -- @param dtime deprecated: ignored now, because of smooth rotations function mob_class:turn_by(angle, delay, dtime) + if self.noyaw then return end -- shulker return self:set_yaw((self.object:get_yaw() or 0) + angle, delay, dtime) end -- Turn into a direction (e.g., to the player, or away) -- @param dtime deprecated: ignored now, because of smooth rotations function mob_class:turn_in_direction(dx, dz, delay, dtime) + if self.noyaw then return end -- shulker if not self.rotate then self.rotate = 0 end if abs(dx) == 0 and abs(dz) == 0 then return self.object:get_yaw() + self.rotate end return self:set_yaw(-atan2(dx, dz) - self.rotate, delay, dtime) + self.rotate