From aa3739528b638bb8e6544119714a8a620bd9e889 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 11 Feb 2019 21:27:17 +0100 Subject: [PATCH] Fix weird arguments given to is_protected --- mods/ITEMS/mcl_core/nodes_base.lua | 6 +++++- mods/ITEMS/mcl_fire/fire_charge.lua | 4 ++-- mods/ITEMS/mcl_fire/flint_and_steel.lua | 4 ++-- mods/ITEMS/mcl_fire/init.lua | 18 +++++++++++++++--- mods/ITEMS/mcl_nether/init.lua | 7 ++++++- mods/ITEMS/mcl_tnt/init.lua | 2 +- 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_base.lua b/mods/ITEMS/mcl_core/nodes_base.lua index f2299e077..237eff39f 100644 --- a/mods/ITEMS/mcl_core/nodes_base.lua +++ b/mods/ITEMS/mcl_core/nodes_base.lua @@ -652,7 +652,11 @@ minetest.register_node("mcl_core:bedrock", { local dim = mcl_worlds.pos_to_dimension(pos) local flame_pos = {x = pos.x, y = pos.y + 1, z = pos.z} local fn = minetest.get_node(flame_pos) - if dim == "end" and fn.name == "air" and not minetest.is_protected(flame_pos, "fire") and pointed_thing.under.y < pointed_thing.above.y then + local pname = player:get_player_name() + if minetest.is_protected(flame_pos, pname) then + return minetest.record_protection_violation(flame_pos, pname) + end + if dim == "end" and fn.name == "air" and pointed_thing.under.y < pointed_thing.above.y then minetest.set_node(flame_pos, {name = "mcl_fire:eternal_fire"}) return true else diff --git a/mods/ITEMS/mcl_fire/fire_charge.lua b/mods/ITEMS/mcl_fire/fire_charge.lua index 26259e04f..d35ffae97 100644 --- a/mods/ITEMS/mcl_fire/fire_charge.lua +++ b/mods/ITEMS/mcl_fire/fire_charge.lua @@ -28,10 +28,10 @@ minetest.register_craftitem("mcl_fire:fire_charge", { if nodedef and nodedef._on_ignite then local overwrite = nodedef._on_ignite(user, pointed_thing) if not overwrite then - mcl_fire.set_fire(pointed_thing) + mcl_fire.set_fire(pointed_thing, user) end else - mcl_fire.set_fire(pointed_thing) + mcl_fire.set_fire(pointed_thing, user) end if not minetest.settings:get_bool("creative_mode") then itemstack:take_item() diff --git a/mods/ITEMS/mcl_fire/flint_and_steel.lua b/mods/ITEMS/mcl_fire/flint_and_steel.lua index 0ab4043f1..7cb114ad1 100644 --- a/mods/ITEMS/mcl_fire/flint_and_steel.lua +++ b/mods/ITEMS/mcl_fire/flint_and_steel.lua @@ -33,10 +33,10 @@ minetest.register_tool("mcl_fire:flint_and_steel", { if nodedef and nodedef._on_ignite then local overwrite = nodedef._on_ignite(user, pointed_thing) if not overwrite then - mcl_fire.set_fire(pointed_thing) + mcl_fire.set_fire(pointed_thing, user) end else - mcl_fire.set_fire(pointed_thing) + mcl_fire.set_fire(pointed_thing, user) end used = true end diff --git a/mods/ITEMS/mcl_fire/init.lua b/mods/ITEMS/mcl_fire/init.lua index 665b13deb..7743d30dd 100644 --- a/mods/ITEMS/mcl_fire/init.lua +++ b/mods/ITEMS/mcl_fire/init.lua @@ -393,10 +393,22 @@ else -- Fire enabled end --- Set pointed_thing on (normal) fire -mcl_fire.set_fire = function(pointed_thing) +-- Set pointed_thing on (normal) fire. +-- * pointed_thing: Pointed thing to ignite +-- * player: Player who sets fire or nil if nobody +mcl_fire.set_fire = function(pointed_thing, player) + local pname + if player == nil then + pname = "" + else + pname = player:get_player_name() + end local n = minetest.get_node(pointed_thing.above) - if n.name == "air" and not minetest.is_protected(pointed_thing.above, "fire") then + if minetest.is_protected(pointed_thing.above, pname) then + minetest.record_protection_violation(pointed_thing.above, pname) + return + end + if n.name == "air" then minetest.add_node(pointed_thing.above, {name="mcl_fire:fire"}) end end diff --git a/mods/ITEMS/mcl_nether/init.lua b/mods/ITEMS/mcl_nether/init.lua index b0bb771a1..4fc36a8b4 100644 --- a/mods/ITEMS/mcl_nether/init.lua +++ b/mods/ITEMS/mcl_nether/init.lua @@ -46,7 +46,12 @@ local eternal_on_ignite = function(player, pointed_thing) local pos = pointed_thing.under local flame_pos = {x = pos.x, y = pos.y + 1, z = pos.z} local fn = minetest.get_node(flame_pos) - if fn.name == "air" and not minetest.is_protected(flame_pos, "fire") and pointed_thing.under.y < pointed_thing.above.y then + local pname = player:get_player_name() + if minetest.is_protected(flame_pos, pname) then + minetest.record_protection_violation(flame_pos, pname) + return + end + if fn.name == "air" and pointed_thing.under.y < pointed_thing.above.y then minetest.set_node(flame_pos, {name = "mcl_fire:eternal_fire"}) return true else diff --git a/mods/ITEMS/mcl_tnt/init.lua b/mods/ITEMS/mcl_tnt/init.lua index 39df3848b..dd6ebc66a 100644 --- a/mods/ITEMS/mcl_tnt/init.lua +++ b/mods/ITEMS/mcl_tnt/init.lua @@ -204,7 +204,7 @@ tnt.boom = function(pos, info) end minetest.sound_play(sound, {pos = pos,gain = 1.0,max_hear_distance = 16,}) local node = minetest.get_node(pos) - if minetest.get_item_group("water") == 1 or minetest.get_item_group("lava") == 1 or minetest.is_protected(pos, "tnt") then + if minetest.get_item_group("water") == 1 or minetest.get_item_group("lava") == 1 then -- Cancel the Explosion return end