From 9aafc28a2009998017753d0aa4d013e3cd8795b6 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 11 Apr 2021 14:47:56 -0400 Subject: [PATCH] Fix mobs nil check during mob_step --- mods/ENTITIES/mcl_mobs/api.lua | 29 ++++++++++++++++------------- mods/ENTITIES/mcl_mobs/spawning.lua | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index e3004d323..fa3e4ad44 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -324,6 +324,8 @@ local collision = function(self) self.object:add_velocity(vel1) + --reenable fire spreading eventually + if object:is_player() then object:add_player_velocity(vel2) @@ -3575,7 +3577,16 @@ end -- main mob function local mob_step = function(self, dtime) - --[[ + if not self or not self.object or not self.object:get_luaentity() then + return false + end + + -- can mob be pushed, if so calculate direction -- do this first to prevent issues + -- you can push mobs when they're in the dead state + if self.pushable then + collision(self) + end + if not self.fire_resistant then mcl_burning.tick(self.object, dtime) end @@ -3598,9 +3609,11 @@ local mob_step = function(self, dtime) if self.jump_sound_cooloff > 0 then self.jump_sound_cooloff = self.jump_sound_cooloff - dtime end + if self.opinion_sound_cooloff > 0 then self.opinion_sound_cooloff = self.opinion_sound_cooloff - dtime end + if falling(self, pos) then -- Return if mob died after falling return @@ -3716,9 +3729,7 @@ local mob_step = function(self, dtime) return end - if not self.object:get_luaentity() then - return false - end + do_jump(self) @@ -3746,11 +3757,10 @@ local mob_step = function(self, dtime) -- Move item around on flowing liquids if def and def.liquidtype == "flowing" then - ]]-- + --[[ Get flowing direction (function call from flowlib), if there's a liquid. NOTE: According to Qwertymine, flowlib.quickflow is only reliable for liquids with a flowing distance of 7. Luckily, this is exactly what we need if we only care about water, which has this flowing distance. ]] - --[[ local vec = flowlib.quick_flow(p, node) -- Just to make sure we don't manipulate the speed for no reason if vec.x ~= 0 or vec.y ~= 0 or vec.z ~= 0 then @@ -3806,13 +3816,6 @@ local mob_step = function(self, dtime) end end end - ]]-- - - -- can mob be pushed, if so calculate direction - if self.pushable then - --c_x, c_y = unpack(collision(self)) - collision(self) - end end diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index ff52128df..f815d8811 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -155,6 +155,7 @@ Overworld regular: local mobs_spawn = minetest.settings:get_bool("mobs_spawn", true) ~= false +mobs_spawn = false -- count how many mobs of one type are inside an area local count_mobs = function(pos,mobtype)