From be0cf5788d7f1c8bb2a0b64a10e94cc6a53cf300 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 5 May 2021 08:54:03 +0200 Subject: [PATCH] mcl_util.deal_damage: Only deal damage to players / mobs that are not already dead --- mods/CORE/mcl_util/init.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index f976457c0..01fd5e8ff 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -484,12 +484,18 @@ function mcl_util.deal_damage(target, damage, mcl_reason) elseif luaentity._cmi_is_mob then -- local puncher = mcl_reason and mcl_reason.direct or target -- target:punch(puncher, 1.0, {full_punch_interval = 1.0, damage_groups = {fleshy = damage}}, vector.direction(puncher:get_pos(), target:get_pos()), damage) - luaentity.health = luaentity.health - damage + if luaentity.health > 0 then + luaentity.health = luaentity.health - damage + end return end end - target:set_hp(target:get_hp() - damage, {_mcl_reason = mcl_reason}) + local hp = target:get_hp() + + if hp > 0 then + target:set_hp(hp - damage, {_mcl_reason = mcl_reason}) + end end function mcl_util.get_hp(obj)