From e4a1134d4f8cbafdf3c4a2c65c1d3107f1a554a3 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 5 Feb 2018 19:11:04 +0100 Subject: [PATCH] More anvil smashing fixes --- mods/ENTITIES/mcl_falling_nodes/init.lua | 15 ++++++++++++--- mods/HELP/mcl_doc/init.lua | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mcl_falling_nodes/init.lua b/mods/ENTITIES/mcl_falling_nodes/init.lua index fc0aac246c..bd4b20d8f1 100644 --- a/mods/ENTITIES/mcl_falling_nodes/init.lua +++ b/mods/ENTITIES/mcl_falling_nodes/init.lua @@ -1,6 +1,10 @@ +local dmes = minetest.get_modpath("mcl_death_messages") ~= nil +local hung = minetest.get_modpath("mcl_hunger") ~= nil + local on_damage_step = function(self, dtime) - -- Cause damage to everything it hits. + -- Cause damage to any player it hits. -- Algorithm based on MC anvils. + -- TODO: Support smashing other objects, too. local pos = self.object:get_pos() if not self._startpos then self._startpos = pos @@ -30,14 +34,19 @@ local on_damage_step = function(self, dtime) hp = 0 end if v:is_player() then + -- TODO: Reduce damage if wearing a helmet local msg if minetest.get_item_group(self.node.name, "anvil") ~= 0 then msg = "%s was smashed by a falling anvil." else msg = "%s was smashed by a falling block." end - mcl_death_messages.player_damage(v, string.format(msg, v:get_player_name())) - mcl_hunger.exhaust(v:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) + if dmes then + mcl_death_messages.player_damage(v, string.format(msg, v:get_player_name())) + end + if hung then + mcl_hunger.exhaust(v:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) + end end v:set_hp(hp) end diff --git a/mods/HELP/mcl_doc/init.lua b/mods/HELP/mcl_doc/init.lua index c7421509b8..b4f292b4cf 100644 --- a/mods/HELP/mcl_doc/init.lua +++ b/mods/HELP/mcl_doc/init.lua @@ -162,7 +162,7 @@ end) doc.sub.items.register_factoid("nodes", "gravity", function(itemstring, def) local s = "" if minetest.get_item_group(itemstring, "crush_after_fall") == 1 then - s = s .. "When this block falls deeper than 1 block, it causes damage to anything it hits. The damage dealt is B×2−2 hit points with B = number of blocks fallen. The damage can never be more than 40 HP." + s = s .. "When this block falls deeper than 1 block, it causes damage to any player it hits. The damage dealt is B×2−2 hit points with B = number of blocks fallen. The damage can never be more than 40 HP." end return s end)