From 7bd0b5a9b1c0dfa5449ac56d36b04f6941aafad3 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 13 Nov 2022 03:16:07 +0100 Subject: [PATCH] Some more missing arg fixes --- mods/ENTITIES/mcl_mobs/api.lua | 5 +++-- mods/ENTITIES/mcl_mobs/effects.lua | 6 +++--- mods/ENTITIES/mcl_mobs/items.lua | 1 + mods/ENTITIES/mcl_mobs/movement.lua | 2 +- mods/ENTITIES/mcl_mobs/physics.lua | 7 +++---- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 935110447..a898ed979 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -303,6 +303,7 @@ end function mob_class:on_step(dtime) self.lifetimer = self.lifetimer - dtime local pos = self.object:get_pos() + if not pos then return end if self:check_despawn(pos) then return true end local d = 0.85 @@ -363,8 +364,8 @@ function mob_class:on_step(dtime) self:follow_flop() --set animation speed relitive to velocity self:set_animation_speed() - self:check_smooth_rotation() - self:check_head_swivel() + self:check_smooth_rotation(dtime) + self:check_head_swivel(dtime) self:do_jump() self:set_armor_texture() diff --git a/mods/ENTITIES/mcl_mobs/effects.lua b/mods/ENTITIES/mcl_mobs/effects.lua index d02b5058b..69ad186d6 100644 --- a/mods/ENTITIES/mcl_mobs/effects.lua +++ b/mods/ENTITIES/mcl_mobs/effects.lua @@ -279,10 +279,10 @@ local function dir_to_pitch(dir) return -math.atan2(-dir.y, xz) end -function mob_class:check_head_swivel() - if self.head_swivel and type(self.head_swivel) == "string" then +function mob_class:check_head_swivel(dtime) + if not self.head_swivel or type(self.head_swivel) ~= "string" then return end local final_rotation = vector.new(0,0,0) - local oldp,oldr = self.object:get_bone_position(self.head_swivel) + local pos = self.object:get_pos() for _, obj in pairs(minetest.get_objects_inside_radius(pos, 10)) do if obj:is_player() and not self.attack or obj:get_luaentity() and obj:get_luaentity().name == self.name and self ~= obj:get_luaentity() then diff --git a/mods/ENTITIES/mcl_mobs/items.lua b/mods/ENTITIES/mcl_mobs/items.lua index 0976fa1a7..267dd8595 100644 --- a/mods/ENTITIES/mcl_mobs/items.lua +++ b/mods/ENTITIES/mcl_mobs/items.lua @@ -59,6 +59,7 @@ end function mob_class:check_item_pickup() if self.pick_up and #self.pick_up > 0 or self.wears_armor then local p = self.object:get_pos() + if not p then return end for _,o in pairs(minetest.get_objects_inside_radius(p,2)) do local l=o:get_luaentity() if l and l.name == "__builtin:item" then diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index eedf65b29..3eed56cbe 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -1355,7 +1355,7 @@ function mob_class:do_states(dtime) end end -function mob_class:check_smooth_rotation() +function mob_class:check_smooth_rotation(dtime) -- smooth rotation by ThomasMonroe314 if self._turn_to then self:set_yaw( self._turn_to, .1) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 1a393f505..a03e21543 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -39,6 +39,7 @@ local function within_limits(pos, radius) wmin = wmin - radius wmax = wmax + radius end + if not pos then return true end for _,v in pairs(pos) do if v < wmin or v > wmax then return false end end @@ -582,6 +583,7 @@ function mob_class:do_env_damage() end local pos = self.object:get_pos() + if not pos then return end self.time_of_day = minetest.get_timeofday() @@ -592,10 +594,7 @@ function mob_class:do_env_damage() return true end - local sunlight = 10 - if within_limits(pos,0) then - sunlight = minetest.get_natural_light(pos, self.time_of_day) - end + local sunlight = minetest.get_natural_light(pos, self.time_of_day) -- bright light harms mob if self.light_damage ~= 0 and (sunlight or 0) > 12 then