mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2025-01-24 07:51:07 +01:00
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 <the-real-herowl@noreply.git.minetest.land> Co-authored-by: kno10 <erich.schubert@gmail.com> Co-committed-by: kno10 <erich.schubert@gmail.com>
This commit is contained in:
parent
f83d8c07ad
commit
28c0a3072c
1 changed files with 2 additions and 0 deletions
|
@ -240,11 +240,13 @@ end
|
||||||
-- Relative turn, primarily for random turning
|
-- Relative turn, primarily for random turning
|
||||||
-- @param dtime deprecated: ignored now, because of smooth rotations
|
-- @param dtime deprecated: ignored now, because of smooth rotations
|
||||||
function mob_class:turn_by(angle, delay, dtime)
|
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)
|
return self:set_yaw((self.object:get_yaw() or 0) + angle, delay, dtime)
|
||||||
end
|
end
|
||||||
-- Turn into a direction (e.g., to the player, or away)
|
-- Turn into a direction (e.g., to the player, or away)
|
||||||
-- @param dtime deprecated: ignored now, because of smooth rotations
|
-- @param dtime deprecated: ignored now, because of smooth rotations
|
||||||
function mob_class:turn_in_direction(dx, dz, delay, dtime)
|
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 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
|
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
|
return self:set_yaw(-atan2(dx, dz) - self.rotate, delay, dtime) + self.rotate
|
||||||
|
|
Loading…
Reference in a new issue