diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index af006d1cc..cdcffd81c 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -821,9 +821,8 @@ function mobs.mob_step(self, dtime) self.lifetimer = self.lifetimer - dtime if self.lifetimer <= 0 then self.lifetimer = self.lifetimer_reset - if not mobs.check_for_player_within_area(self, 64) then - --print("removing in MAIN LOGIC!") - self.object:remove() + if mobs.can_despawn(self) then + self.object:remove() return end end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua index 65ba764f6..b9cf2f669 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua @@ -5,16 +5,18 @@ local minetest_settings = minetest.settings -- CMI support check local use_cmi = minetest.global_exists("cmi") +mobs.can_despawn = function(self) + return (not self.tamed and not self.bred and not self.nametag and + not mobs.check_for_player_within_area(self, 64)); +end + -- get entity staticdata mobs.mob_staticdata = function(self) --despawn mechanism --don't despawned tamed or bred mobs - if not self.tamed and not self.bred then - if not mobs.check_for_player_within_area(self, 64) then - --print("removing SERIALIZED!") - self.object:remove() - return - end + if mobs.can_despawn(self) then + self.object:remove() + return end self.remove_ok = true