diff --git a/mods/CORE/mcl_damage/init.lua b/mods/CORE/mcl_damage/init.lua index 983b82b49..8b2acbb35 100644 --- a/mods/CORE/mcl_damage/init.lua +++ b/mods/CORE/mcl_damage/init.lua @@ -149,13 +149,18 @@ minetest.register_on_player_hpchange(function(player, hp_change, mt_reason) end, true) minetest.register_on_player_hpchange(function(player, hp_change, mt_reason) - if hp_change < 0 then - mcl_damage.run_damage_callbacks(player, -hp_change, mcl_damage.from_mt(mt_reason)) + if player:get_hp() > 0 then + mt_reason.approved = true + if hp_change < 0 then + mcl_damage.run_damage_callbacks(player, -hp_change, mcl_damage.from_mt(mt_reason)) + end end end, false) minetest.register_on_dieplayer(function(player, mt_reason) - mcl_damage.run_death_callbacks(player, mcl_damage.from_mt(mt_reason)) + if mt_reason.approved then + mcl_damage.run_death_callbacks(player, mcl_damage.from_mt(mt_reason)) + end end) minetest.register_on_mods_loaded(function() diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 01fd5e8ff..1bf3add38 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -539,7 +539,7 @@ function mcl_util.get_object_name(object) local luaentity = object:get_luaentity() if not luaentity then - return "" + return tostring(object) end return luaentity.nametag and luaentity.nametag ~= "" and luaentity.nametag or luaentity.description or luaentity.name diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua index fd95b60ef..57cb6e4e5 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua @@ -87,6 +87,12 @@ end mobs.death_logic = function(self, dtime) + + --stop crashing game when object is nil + if not self or not self.object or not self.object:get_luaentity() then + return + end + self.death_animation_timer = self.death_animation_timer + dtime --get all attached entities and sort through them diff --git a/mods/HUD/mcl_death_messages/init.lua b/mods/HUD/mcl_death_messages/init.lua index 9087c41e9..0432c3488 100644 --- a/mods/HUD/mcl_death_messages/init.lua +++ b/mods/HUD/mcl_death_messages/init.lua @@ -204,8 +204,9 @@ mcl_damage.register_on_death(function(obj, reason) if obj:is_player() then send_to = true - end -- ToDo: add mob death messages for owned mobs, only send to owner (sent_to = "player name") + end + -- ToDo: add mob death messages for owned mobs, only send to owner (sent_to = "player name") if send_to then local messages = mcl_death_messages.messages[reason.type] or {} diff --git a/mods/ITEMS/mcl_end/end_crystal.lua b/mods/ITEMS/mcl_end/end_crystal.lua index 720d8ed8d..78fcc0e21 100644 --- a/mods/ITEMS/mcl_end/end_crystal.lua +++ b/mods/ITEMS/mcl_end/end_crystal.lua @@ -27,8 +27,16 @@ end local function crystal_explode(self, puncher) if self._exploded then return end self._exploded = true - local strength = puncher and explosion_strength or 1 - mcl_explosions.explode(vector.add(self.object:get_pos(), {x = 0, y = 1.5, z = 0}), strength, {drop_chance = 1}, puncher) + local strength = 1 + local source + if puncher then + strength = explosion_strength + local reason = {} + mcl_damage.from_punch(reason, puncher) + mcl_damage.finish_reason(reason) + source = reason.source + end + mcl_explosions.explode(vector.add(self.object:get_pos(), {x = 0, y = 1.5, z = 0}), strength, {drop_chance = 1}, self.object, source) minetest.after(0, self.object.remove, self.object) end