From ac54e3caf3709fa9dcc80874a535437ea9b4f5b5 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 4 Jan 2021 16:40:18 +0100 Subject: [PATCH 1/2] Fix despawning once and for all (hopefully) --- mods/ENTITIES/mcl_mobs/api.lua | 57 ++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index da2543645..bb558cd86 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -3586,35 +3586,20 @@ local mob_step = function(self, dtime) and ((not self.nametag) or (self.nametag == "")) then self.lifetimer = self.lifetimer - dtime - if self.lifetimer <= 10 then - - -- only despawn away from player - local far_objs = minetest.get_objects_inside_radius(pos, 48) - for n = 1, #far_objs do - - if far_objs[n]:is_player() then - - local close_objs = minetest.get_objects_inside_radius(pos, 16) - for n = 1, #close_objs do - if close_objs[n]:is_player() then - self.lifetimer = 20 - return - end - end - if math.random(1, 10) <= 3 then - minetest.log("action", "Mob "..self.name.." despawns in mob_step at "..minetest.pos_to_string(pos)) - mcl_burning.extinguish(self.object) - self.object:remove() - return - end - else - minetest.log("action", "Mob "..self.name.." despawns in mob_step at "..minetest.pos_to_string(pos)) - mcl_burning.extinguish(self.object) - self.object:remove() - return - end + local despawn = self.despawn_immediately + if not despawn and self.lifetimer <= 10 then + if math.random(10) < 4 then + despawn = true + else + self.lifetimer = 20 end end + if despawn then + minetest.log("action", "Mob "..self.name.." despawns in mob_step at "..minetest.pos_to_string(pos)) + mcl_burning.extinguish(self.object) + self.object:remove() + end + self.despawn_immediately = true end end @@ -4556,3 +4541,21 @@ function mobs:alias_mob(old_name, new_name) }) end + +minetest.register_globalstep(function() + for _, player in ipairs(minetest.get_connected_players()) do + local pos = player:get_pos() + for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 24)) do + local lua = obj:get_luaentity() + if lua and lua._cmi_is_mob then + lua.lifetimer = 20 + end + end + for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 32)) do + local lua = obj:get_luaentity() + if lua and lua._cmi_is_mob then + lua.despawn_immediately = false + end + end + end +end) From aea051fe37a80dcdf51774d30066c0010d2f5d17 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 4 Jan 2021 17:53:49 +0100 Subject: [PATCH 2/2] Proper fire aspect damage --- mods/ITEMS/mcl_enchanting/enchantments.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_enchanting/enchantments.lua b/mods/ITEMS/mcl_enchanting/enchantments.lua index d79cb8375..3b9513e2c 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -195,7 +195,7 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, if wielditem then local fire_aspect_level = mcl_enchanting.get_enchantment(wielditem, "fire_aspect") if fire_aspect_level > 0 then - mcl_burning.set_on_fire(player, 4, fire_aspect_level * 2, hitter:get_player_name()) + mcl_burning.set_on_fire(player, 4, fire_aspect_level * 4 - 1, hitter:get_player_name()) end end end @@ -704,7 +704,7 @@ mcl_enchanting.enchantments.unbreaking = { weight = 5, description = S("Increases item durability."), curse = false, - on_enchant = function(itemstack, level) + on_enchant = function(itemstack, level) local tool_capabilities = itemstack:get_tool_capabilities() for group, capability in pairs(tool_capabilities.groupcaps) do capability.uses = capability.uses * (1 + level)