From 4cf4cdebf0759fd57ec27c3caf9903d0aa5526aa Mon Sep 17 00:00:00 2001 From: teknomunk Date: Wed, 12 Jun 2024 22:05:13 -0500 Subject: [PATCH] Add additional gamerules for damage types --- mods/CORE/mcl_damage/init.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mods/CORE/mcl_damage/init.lua b/mods/CORE/mcl_damage/init.lua index 3394a779b..0bed3ceff 100644 --- a/mods/CORE/mcl_damage/init.lua +++ b/mods/CORE/mcl_damage/init.lua @@ -37,6 +37,15 @@ mcl_damage = { local damage_enabled = vl_tuning.setting("damage_enabled", "bool",{ default = minetest.settings:get_bool("enabled_damage",true) }) +local fall_damage_enabled = vl_tuning.setting("gamerule:fallDamage", "bool", { + default = true +}) +local drowning_damage_enabled = vl_tuning.setting("gamerule:drowningDamage", "bool", { + default = true +}) +local fire_damage_enabled = vl_tuning.setting("gamerule:fireDamage", "bool", { + default = true +}) function mcl_damage.register_modifier(func, priority) table.insert(mcl_damage.modifiers, {func = func, priority = priority or 0}) @@ -155,10 +164,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) + -- Check if damage is enabled if not damage_enabled[1] then return 0 end + local mcl_reason = mcl_damage.from_mt(mt_reason) + if not fire_damage_enabled[1] and mcl_reason.type == "fire" then return 0 end + if not drowning_damage_enabled[1] and mcl_reason.type == "drown" then return 0 end + if not fall_damage_enabled[1] and mcl_reason.type == "fall" then return 0 end + if player:get_hp() > 0 then if hp_change < 0 then - mcl_damage.run_damage_callbacks(player, -hp_change, mcl_damage.from_mt(mt_reason)) + mcl_damage.run_damage_callbacks(player, -hp_change, mcl_reason) end end end, false)