From dc0b655109b38205905d9306dd271589762f1c81 Mon Sep 17 00:00:00 2001 From: James David Clarke Date: Fri, 5 Jan 2024 00:46:50 +0000 Subject: [PATCH] Fix --- init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index da4f6c1..21a5e94 100644 --- a/init.lua +++ b/init.lua @@ -52,8 +52,9 @@ if minetest.get_modpath("mcl_inventory") then -- Override the damage handling function local original_damage_function = mcl_damage.run_modifiers mcl_damage.run_modifiers = function(obj, damage, reason) - -- Check if the damage is caused by a projectile and both entities involved are players - if (reason.type == "arrow" or reason.type == "fireball") and obj:is_player() and reason.source and reason.source:is_player() then + -- Check if obj and reason.source are valid and if the damage is caused by a projectile + if obj and obj:is_player() and reason.source and reason.source:is_player() and + (reason.type == "arrow" or reason.type == "fireball") then -- Check PvP settings for both players if not is_pvp_enabled(obj) or not is_pvp_enabled(reason.source) then return 0 -- No damage if PvP is disabled for either player @@ -63,6 +64,7 @@ if minetest.get_modpath("mcl_inventory") then -- Call the original damage function for all other cases return original_damage_function(obj, damage, reason) end + minetest.log("action", "[PvP Mod] mcl_inventory modpath found. Registering PvP tab.") mcl_inventory.register_survival_inventory_tab({