From 9a3c6a3fd7b88f1f65b208b1b1c4f2b5f95e708d Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 8 Feb 2019 22:17:51 +0100 Subject: [PATCH] Protect: add bottles, mobspawner, fix repeater --- mods/ENTITIES/mcl_mobs/api.lua | 4 ++ mods/ITEMS/REDSTONE/mesecons_delayer/init.lua | 4 +- mods/ITEMS/mcl_potions/init.lua | 63 ++++++++++++------- 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index ebe977e94..a75a6e397 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -3577,6 +3577,10 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative) local name = placer:get_player_name() local privs = minetest.get_player_privs(name) if mod_mobspawners and under.name == "mcl_mobspawners:spawner" then + if minetest.is_protected(pointed_thing.under, name) then + minetest.record_protection_violation(pointed_thing.under, name) + return itemstack + end if not privs.maphack then minetest.chat_send_player(name, "You need the “maphack” privilege to change the mob spawner.") return itemstack diff --git a/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua b/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua index ea4638442..a17dd7f5a 100644 --- a/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua @@ -257,7 +257,7 @@ minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), { on_rightclick = function (pos, node, clicker) local protname = clicker:get_player_name() if minetest.is_protected(pos, protname) then - minetest.report_protection_violation(pos, protname) + minetest.record_protection_violation(pos, protname) return end if node.name=="mesecons_delayer:delayer_off_1" then @@ -325,7 +325,7 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), { on_rightclick = function (pos, node, clicker) local protname = clicker:get_player_name() if minetest.is_protected(pos, protname) then - minetest.report_protection_violation(pos, protname) + minetest.record_protection_violation(pos, protname) return end if node.name=="mesecons_delayer:delayer_on_1" then diff --git a/mods/ITEMS/mcl_potions/init.lua b/mods/ITEMS/mcl_potions/init.lua index fa4349c03..2920cfdd2 100644 --- a/mods/ITEMS/mcl_potions/init.lua +++ b/mods/ITEMS/mcl_potions/init.lua @@ -46,27 +46,34 @@ minetest.register_craftitem("mcl_potions:glass_bottle", { get_water = true river_water = node.name == "mclx_core:river_water_source" -- Or reduce water level of cauldron by 1 - elseif node.name == "mcl_cauldrons:cauldron_3" then - get_water = true - minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_2"}) - elseif node.name == "mcl_cauldrons:cauldron_2" then - get_water = true - minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_1"}) - elseif node.name == "mcl_cauldrons:cauldron_1" then - get_water = true - minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) - elseif node.name == "mcl_cauldrons:cauldron_3r" then - get_water = true - river_water = true - minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_2r"}) - elseif node.name == "mcl_cauldrons:cauldron_2r" then - get_water = true - river_water = true - minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_1r"}) - elseif node.name == "mcl_cauldrons:cauldron_1r" then - get_water = true - river_water = true - minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) + elseif string.sub(node.name, 1, 14) == "mcl_cauldrons:" then + local pname = placer:get_player_name() + if minetest.is_protected(pointed_thing.under, pname) then + minetest.record_protection_violation(pointed_thing.under, pname) + return itemstack + end + if node.name == "mcl_cauldrons:cauldron_3" then + get_water = true + minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_2"}) + elseif node.name == "mcl_cauldrons:cauldron_2" then + get_water = true + minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_1"}) + elseif node.name == "mcl_cauldrons:cauldron_1" then + get_water = true + minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) + elseif node.name == "mcl_cauldrons:cauldron_3r" then + get_water = true + river_water = true + minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_2r"}) + elseif node.name == "mcl_cauldrons:cauldron_2r" then + get_water = true + river_water = true + minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_1r"}) + elseif node.name == "mcl_cauldrons:cauldron_1r" then + get_water = true + river_water = true + minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) + end end if get_water then -- Replace with water bottle, if possible, otherwise @@ -160,7 +167,12 @@ minetest.register_craftitem("mcl_potions:potion_water", { local cauldron = fill_cauldron(node.name, "mcl_core:water_source") if cauldron then - -- Increase water level of cauldron by 1 + local pname = placer:get_player_name() + if minetest.is_protected(pointed_thing.under, pname) then + minetest.record_protection_violation(pointed_thing.under, pname) + return itemstack + end + -- Increase water level of cauldron by 1 minetest.set_node(pointed_thing.under, {name=cauldron}) minetest.sound_play("mcl_potions_bottle_pour", {pos=pointed_thing.under, gain=0.5, max_hear_range=16}) return "mcl_potions:glass_bottle" @@ -195,7 +207,12 @@ minetest.register_craftitem("mcl_potions:potion_river_water", { local cauldron = fill_cauldron(node.name, "mclx_core:river_water_source") if cauldron then - -- Increase water level of cauldron by 1 + local pname = placer:get_player_name() + if minetest.is_protected(pointed_thing.under, pname) then + minetest.record_protection_violation(pointed_thing.under, pname) + return itemstack + end + -- Increase water level of cauldron by 1 minetest.set_node(pointed_thing.under, {name=cauldron}) minetest.sound_play("mcl_potions_bottle_pour", {pos=pointed_thing.under, gain=0.5, max_hear_range=16}) return "mcl_potions:glass_bottle"