From 43539e1392192b4202a91f4d756416e15bfa31cf Mon Sep 17 00:00:00 2001
From: the-real-herowl <wiktor_t-i@proton.me>
Date: Sun, 29 Dec 2024 08:05:52 +0100
Subject: [PATCH] Make sure self.rotate is not nil before use (#4759)

Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4759
Co-authored-by: the-real-herowl <wiktor_t-i@proton.me>
Co-committed-by: the-real-herowl <wiktor_t-i@proton.me>
---
 mods/ENTITIES/mcl_mobs/physics.lua | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua
index b93df7627..7db0e8166 100644
--- a/mods/ENTITIES/mcl_mobs/physics.lua
+++ b/mods/ENTITIES/mcl_mobs/physics.lua
@@ -245,6 +245,7 @@ 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 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
 end