From 1bd647507b6479e5c44f5686e7d18ddbc6cf8b8b Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 5 May 2021 13:20:06 +0200 Subject: [PATCH 1/5] Add proper end crystal death message --- mods/ITEMS/mcl_end/end_crystal.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 From f53ff8418f6f9628c3efbf9bf80afdf02a505558 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 5 May 2021 13:24:23 +0200 Subject: [PATCH 2/5] mcl_damage: HP check guard in non-modifier on_hpchange callback and usage of raw tostring for deactivated objects for death messages --- mods/CORE/mcl_damage/init.lua | 2 +- mods/CORE/mcl_util/init.lua | 2 +- mods/HUD/mcl_death_messages/init.lua | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mods/CORE/mcl_damage/init.lua b/mods/CORE/mcl_damage/init.lua index 983b82b49..c6f91d414 100644 --- a/mods/CORE/mcl_damage/init.lua +++ b/mods/CORE/mcl_damage/init.lua @@ -149,7 +149,7 @@ 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 + if hp_change < 0 and player:get_hp() > 0 then mcl_damage.run_damage_callbacks(player, -hp_change, mcl_damage.from_mt(mt_reason)) end end, false) 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/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 {} From 35a2a2b91288fa35ff97fe4e84897c429850fb9e Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 5 May 2021 13:27:30 +0200 Subject: [PATCH 3/5] Workaround to prevent double death messages --- mods/CORE/mcl_damage/init.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mods/CORE/mcl_damage/init.lua b/mods/CORE/mcl_damage/init.lua index c6f91d414..df2ecd58d 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 and player:get_hp() > 0 then + if hp_change < 0 then mcl_damage.run_damage_callbacks(player, -hp_change, mcl_damage.from_mt(mt_reason)) end + if player:get_hp() > 0 then + mt_reason._mcl_approved = true + 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._mcl_approved then + mcl_damage.run_death_callbacks(player, mcl_damage.from_mt(mt_reason)) + end end) minetest.register_on_mods_loaded(function() From 4b327bcf99338a28ec505289cbafcbb9f74b25dc Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 5 May 2021 14:41:23 +0200 Subject: [PATCH 4/5] Minor fix to prevent writing the damage reason approval field into MCL damage reason and calling passive damage handlers on dead players --- mods/CORE/mcl_damage/init.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mods/CORE/mcl_damage/init.lua b/mods/CORE/mcl_damage/init.lua index df2ecd58d..8b2acbb35 100644 --- a/mods/CORE/mcl_damage/init.lua +++ b/mods/CORE/mcl_damage/init.lua @@ -149,16 +149,16 @@ 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)) - end if player:get_hp() > 0 then - mt_reason._mcl_approved = true + 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) - if mt_reason._mcl_approved then + if mt_reason.approved then mcl_damage.run_death_callbacks(player, mcl_damage.from_mt(mt_reason)) end end) From 37350e81c94419003f14f2fde04aec8a7727941c Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Wed, 5 May 2021 12:52:07 -0400 Subject: [PATCH 5/5] Stop crashing when mob object is already deleted --- mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua | 6 ++++++ 1 file changed, 6 insertions(+) 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