Check protection for most nodes

This commit is contained in:
Wuzzy 2019-02-08 21:59:01 +01:00
parent bcf7125f9d
commit 312b17a958
18 changed files with 389 additions and 26 deletions

@ -153,7 +153,12 @@ end
local make_rightclick_handler = function(state, mode) local make_rightclick_handler = function(state, mode)
local newnodename = local newnodename =
"mcl_comparators:comparator_"..state.."_"..flipmode(mode) "mcl_comparators:comparator_"..state.."_"..flipmode(mode)
return function (pos, node) return function (pos, node, clicker)
local protname = clicker:get_player_name()
if minetest.is_protected(pos, protname) then
minetest.record_protection_violation(pos, protname)
return
end
minetest.swap_node(pos, {name = newnodename, param2 = node.param2 }) minetest.swap_node(pos, {name = newnodename, param2 = node.param2 })
end end
end end

@ -50,6 +50,33 @@ end
local dispenserdef = { local dispenserdef = {
is_ground_content = false, is_ground_content = false,
sounds = mcl_sounds.node_sound_stone_defaults(), sounds = mcl_sounds.node_sound_stone_defaults(),
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return count
end
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local meta2 = meta local meta2 = meta

@ -63,6 +63,33 @@ local dropperdef = {
end end
meta:from_table(meta2:to_table()) meta:from_table(meta2:to_table())
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return count
end
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end,
_mcl_blast_resistance = 17.5, _mcl_blast_resistance = 17.5,
_mcl_hardness = 3.5, _mcl_hardness = 3.5,
mesecons = {effector = { mesecons = {effector = {

@ -131,9 +131,14 @@ local on_rightclick = function(pos, node, player, itemstack, pointed_thing)
if not minetest.settings:get_bool("creative_mode") then if not minetest.settings:get_bool("creative_mode") then
return return
end end
local privs = minetest.get_player_privs(player:get_player_name()) local pname = player:get_player_name()
if minetest.is_protected(pos, pname) then
minetest.record_protection_violation(pos, pname)
return
end
local privs = minetest.get_player_privs(pname)
if not privs.maphack then if not privs.maphack then
minetest.chat_send_player(player:get_player_name(), "Access denied. You need the “maphack” privilege to edit command blocks.") minetest.chat_send_player(pname, "Access denied. You need the “maphack” privilege to edit command blocks.")
return return
end end
@ -152,7 +157,7 @@ local on_rightclick = function(pos, node, player, itemstack, pointed_thing)
"image_button[8,4.5;1,1;doc_button_icon_lores.png;doc;]" .. "image_button[8,4.5;1,1;doc_button_icon_lores.png;doc;]" ..
"label[0,4;"..minetest.formspec_escape(commanderstr).."]" .. "label[0,4;"..minetest.formspec_escape(commanderstr).."]" ..
"tooltip[doc;Help]" "tooltip[doc;Help]"
minetest.show_formspec(player:get_player_name(), "commandblock_"..pos.x.."_"..pos.y.."_"..pos.z, formspec) minetest.show_formspec(pname, "commandblock_"..pos.x.."_"..pos.y.."_"..pos.z, formspec)
end end
local on_place = function(itemstack, placer, pointed_thing) local on_place = function(itemstack, placer, pointed_thing)

@ -254,7 +254,12 @@ minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), {
sunlight_propagates = false, sunlight_propagates = false,
is_ground_content = false, is_ground_content = false,
drop = 'mesecons_delayer:delayer_off_1', drop = 'mesecons_delayer:delayer_off_1',
on_rightclick = function (pos, node) 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)
return
end
if node.name=="mesecons_delayer:delayer_off_1" then if node.name=="mesecons_delayer:delayer_off_1" then
minetest.set_node(pos, {name="mesecons_delayer:delayer_off_2", param2=node.param2}) minetest.set_node(pos, {name="mesecons_delayer:delayer_off_2", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_off_2" then elseif node.name=="mesecons_delayer:delayer_off_2" then
@ -317,7 +322,12 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), {
sunlight_propagates = false, sunlight_propagates = false,
is_ground_content = false, is_ground_content = false,
drop = 'mesecons_delayer:delayer_off_1', drop = 'mesecons_delayer:delayer_off_1',
on_rightclick = function (pos, node) 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)
return
end
if node.name=="mesecons_delayer:delayer_on_1" then if node.name=="mesecons_delayer:delayer_on_1" then
minetest.set_node(pos, {name="mesecons_delayer:delayer_on_2",param2=node.param2}) minetest.set_node(pos, {name="mesecons_delayer:delayer_on_2",param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_on_2" then elseif node.name=="mesecons_delayer:delayer_on_2" then

@ -14,7 +14,12 @@ The note block will only play a note when it is below air, otherwise, it stays s
groups = {handy=1,axey=1, material_wood=1}, groups = {handy=1,axey=1, material_wood=1},
is_ground_content = false, is_ground_content = false,
place_param2 = 0, place_param2 = 0,
on_rightclick = function (pos, node) -- change sound when rightclicked on_rightclick = function (pos, node, clicker) -- change sound when rightclicked
local protname = clicker:get_player_name()
if minetest.is_protected(pos, protname) then
minetest.record_protection_violation(pos, protname)
return
end
node.param2 = (node.param2+1)%24 node.param2 = (node.param2+1)%24
mesecon.noteblock_play(pos, node.param2) mesecon.noteblock_play(pos, node.param2)
minetest.set_node(pos, node) minetest.set_node(pos, node)

@ -27,6 +27,11 @@ minetest.register_node("mesecons_solarpanel:solar_panel_on", {
rules = mesecon.rules.pplate, rules = mesecon.rules.pplate,
}}, }},
on_rightclick = function(pos, node, clicker, pointed_thing) on_rightclick = function(pos, node, clicker, pointed_thing)
local protname = clicker:get_player_name()
if minetest.is_protected(pos, protname) then
minetest.record_protection_violation(pos, protname)
return
end
minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_inverted_off"}) minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_inverted_off"})
mesecon.receptor_off(pos, mesecon.rules.pplate) mesecon.receptor_off(pos, mesecon.rules.pplate)
end, end,
@ -60,6 +65,11 @@ minetest.register_node("mesecons_solarpanel:solar_panel_off", {
rules = mesecon.rules.pplate, rules = mesecon.rules.pplate,
}}, }},
on_rightclick = function(pos, node, clicker, pointed_thing) on_rightclick = function(pos, node, clicker, pointed_thing)
local protname = clicker:get_player_name()
if minetest.is_protected(pos, protname) then
minetest.record_protection_violation(pos, protname)
return
end
minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_inverted_on"}) minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_inverted_on"})
mesecon.receptor_on(pos, mesecon.rules.pplate) mesecon.receptor_on(pos, mesecon.rules.pplate)
end, end,
@ -134,6 +144,11 @@ minetest.register_node("mesecons_solarpanel:solar_panel_inverted_on", {
rules = mesecon.rules.pplate, rules = mesecon.rules.pplate,
}}, }},
on_rightclick = function(pos, node, clicker, pointed_thing) on_rightclick = function(pos, node, clicker, pointed_thing)
local protname = clicker:get_player_name()
if minetest.is_protected(pos, protname) then
minetest.record_protection_violation(pos, protname)
return
end
minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_off"}) minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_off"})
mesecon.receptor_off(pos, mesecon.rules.pplate) mesecon.receptor_off(pos, mesecon.rules.pplate)
end, end,
@ -168,6 +183,11 @@ minetest.register_node("mesecons_solarpanel:solar_panel_inverted_off", {
rules = mesecon.rules.pplate, rules = mesecon.rules.pplate,
}}, }},
on_rightclick = function(pos, node, clicker, pointed_thing) on_rightclick = function(pos, node, clicker, pointed_thing)
local protname = clicker:get_player_name()
if minetest.is_protected(pos, protname) then
minetest.record_protection_violation(pos, protname)
return
end
minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_on"}) minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_on"})
mesecon.receptor_on(pos, mesecon.rules.pplate) mesecon.receptor_on(pos, mesecon.rules.pplate)
end, end,

@ -277,15 +277,32 @@ local anvildef = {
drop_anvil_items(pos, meta) drop_anvil_items(pos, meta)
meta:from_table(meta2:to_table()) meta:from_table(meta2:to_table())
end, end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == "output" then local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
elseif listname == "output" then
return 0 return 0
else else
return stack:get_count() return stack:get_count()
end end
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
if to_list == "output" then local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
elseif to_list == "output" then
return 0 return 0
elseif from_list == "output" and to_list == "input" then elseif from_list == "output" and to_list == "input" then
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)

@ -53,7 +53,8 @@ end
-- name = user-visible bucket description -- name = user-visible bucket description
-- longdesc = long explanatory description (for help) -- longdesc = long explanatory description (for help)
-- usagehelp = short usage explanation (for help) -- usagehelp = short usage explanation (for help)
-- extra_check = optional function(pos) which can returns false to avoid placing the liquid -- extra_check(pos, placer) = optional function(pos) which can returns false to avoid placing the liquid.
-- placer is object/player who is placing the liquid, can be nil
-- groups = optional list of item groups -- groups = optional list of item groups
-- --
-- This function can be called from any mod (which depends on this one) -- This function can be called from any mod (which depends on this one)
@ -103,12 +104,13 @@ function mcl_buckets.register_liquid(source_place, source_take, itemname, invent
-- Check if pointing to a buildable node -- Check if pointing to a buildable node
local item = itemstack:get_name() local item = itemstack:get_name()
if extra_check and extra_check(place_pos) == false then if extra_check and extra_check(place_pos, user) == false then
-- Fail placement of liquid -- Fail placement of liquid
elseif minetest.registered_nodes[nn] and minetest.registered_nodes[nn].buildable_to then elseif minetest.registered_nodes[nn] and minetest.registered_nodes[nn].buildable_to then
-- buildable; replace the node -- buildable; replace the node
local pns = user:get_player_name() local pns = user:get_player_name()
if minetest.is_protected(place_pos, pns) then if minetest.is_protected(place_pos, pns) then
minetest.record_protection_violation(place_pos, pns)
return itemstack return itemstack
end end
place_liquid(place_pos, node_place) place_liquid(place_pos, node_place)
@ -122,6 +124,7 @@ function mcl_buckets.register_liquid(source_place, source_take, itemname, invent
if minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to then if minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to then
local pn = user:get_player_name() local pn = user:get_player_name()
if minetest.is_protected(pointed_thing.above, pn) then if minetest.is_protected(pointed_thing.above, pn) then
minetest.record_protection_violation(pointed_thing.above, pn)
return itemstack return itemstack
end end
place_liquid(pointed_thing.above, node_place) place_liquid(pointed_thing.above, node_place)
@ -159,11 +162,12 @@ function mcl_buckets.register_liquid(source_place, source_take, itemname, invent
local iname = stack:get_name() local iname = stack:get_name()
local buildable = minetest.registered_nodes[dropnode.name].buildable_to local buildable = minetest.registered_nodes[dropnode.name].buildable_to
if extra_check and extra_check(droppos) == false then if extra_check and extra_check(droppos, nil) == false then
-- Fail placement of liquid -- Fail placement of liquid
elseif buildable then elseif buildable then
-- buildable; replace the node -- buildable; replace the node
if minetest.is_protected(droppos, "") then if minetest.is_protected(droppos, "") then
minetest.record_protection_violation(droppos, "")
return stack return stack
end end
local node_place local node_place
@ -192,7 +196,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
-- Must be pointing to node -- Must be pointing to node
if pointed_thing.type ~= "node" then if pointed_thing.type ~= "node" then
return return itemstack
end end
-- Call on_rightclick if the pointed node defines it -- Call on_rightclick if the pointed node defines it
@ -204,6 +208,12 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", {
end end
end end
-- Can't steal liquids
if minetest.is_protected(pointed_thing.above, pointed_thing.under) then
minetest.record_protection_violation(pointed_thing.under, user:get_player_name())
return itemstack
end
-- Check if pointing to a liquid source -- Check if pointing to a liquid source
local liquiddef = mcl_buckets.liquids[nn] local liquiddef = mcl_buckets.liquids[nn]
local new_bucket local new_bucket
@ -257,6 +267,11 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", {
end end
end, end,
_on_dispense = function(stack, pos, droppos, dropnode, dropdir) _on_dispense = function(stack, pos, droppos, dropnode, dropdir)
if minetest.is_protected(droppos, "") then
minetest.record_protection_violation(droppos, "")
return stack
end
-- Fill empty bucket with liquid or drop bucket if no liquid -- Fill empty bucket with liquid or drop bucket if no liquid
local collect_liquid = false local collect_liquid = false
@ -310,7 +325,13 @@ if mod_mcl_core then
"Water Bucket", "Water Bucket",
"A bucket can be used to collect and release liquids. This one is filled with water.", "A bucket can be used to collect and release liquids. This one is filled with water.",
"Right-click on any block to empty the bucket and put a water source on this spot.", "Right-click on any block to empty the bucket and put a water source on this spot.",
function(pos) function(pos, placer)
-- Check protection
local placer_name = placer:get_player_name()
if minetest.is_protected(pos, placer_name) then
minetest.record_protection_violation(pos, placer_name)
return false
end
local nn = minetest.get_node(pos).name local nn = minetest.get_node(pos).name
-- Pour water into cauldron -- Pour water into cauldron
if minetest.get_item_group(nn, "cauldron") ~= 0 then if minetest.get_item_group(nn, "cauldron") ~= 0 then
@ -343,7 +364,13 @@ if mod_mclx_core then
"River Water Bucket", "River Water Bucket",
"A bucket can be used to collect and release liquids. This one is filled with river water.", "A bucket can be used to collect and release liquids. This one is filled with river water.",
"Right-click on any block to empty the bucket and put a river water source on this spot.", "Right-click on any block to empty the bucket and put a river water source on this spot.",
function(pos) function(pos, placer)
-- Check protection
local placer_name = placer:get_player_name()
if minetest.is_protected(pos, placer_name) then
minetest.record_protection_violation(pos, placer_name)
return false
end
local nn = minetest.get_node(pos).name local nn = minetest.get_node(pos).name
-- Pour into cauldron -- Pour into cauldron
if minetest.get_item_group(nn, "cauldron") ~= 0 then if minetest.get_item_group(nn, "cauldron") ~= 0 then

@ -49,6 +49,12 @@ minetest.register_node("mcl_cake:cake", {
groups = {handy=1, cake=7, food=2,no_eat_delay=1, attached_node=1, dig_by_piston=1, comparator_signal=14}, groups = {handy=1, cake=7, food=2,no_eat_delay=1, attached_node=1, dig_by_piston=1, comparator_signal=14},
drop = '', drop = '',
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
-- Cake is subject to protection
local name = clicker:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return
end
local newcake = minetest.do_item_eat(2, ItemStack("mcl_cake:cake_6"), ItemStack("mcl_cake:cake"), clicker, {type="nothing"}) local newcake = minetest.do_item_eat(2, ItemStack("mcl_cake:cake_6"), ItemStack("mcl_cake:cake"), clicker, {type="nothing"})
-- Check if we were allowed to eat -- Check if we were allowed to eat
if newcake:get_name() ~= "mcl_cake:cake" or minetest.settings:get_bool("creative_mode") == true then if newcake:get_name() ~= "mcl_cake:cake" or minetest.settings:get_bool("creative_mode") == true then
@ -69,6 +75,11 @@ local register_slice = function(level, nodebox, desc)
local on_rightclick local on_rightclick
if level > 1 then if level > 1 then
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
local name = clicker:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return
end
local newcake = minetest.do_item_eat(2, ItemStack(after_eat), ItemStack(this), clicker, {type="nothing"}) local newcake = minetest.do_item_eat(2, ItemStack(after_eat), ItemStack(this), clicker, {type="nothing"})
-- Check if we were allowed to eat -- Check if we were allowed to eat
if newcake:get_name() ~= this or minetest.settings:get_bool("creative_mode") == true then if newcake:get_name() ~= this or minetest.settings:get_bool("creative_mode") == true then
@ -78,6 +89,11 @@ local register_slice = function(level, nodebox, desc)
else else
-- Last slice -- Last slice
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
local name = clicker:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return
end
local newcake = minetest.do_item_eat(2, ItemStack("mcl:cake:cake 0"), ItemStack("mcl_cake:cake_1"), clicker, {type="nothing"}) local newcake = minetest.do_item_eat(2, ItemStack("mcl:cake:cake 0"), ItemStack("mcl_cake:cake_1"), clicker, {type="nothing"})
-- Check if we were allowed to eat -- Check if we were allowed to eat
if newcake:get_name() ~= this or minetest.settings:get_bool("creative_mode") == true then if newcake:get_name() ~= this or minetest.settings:get_bool("creative_mode") == true then

@ -15,6 +15,26 @@ local player_chest_open = function(player, pos)
open_chests[player:get_player_name()] = { pos = pos } open_chests[player:get_player_name()] = { pos = pos }
end end
-- Simple protection checking functions
local protection_check_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return count
end
end
local protection_check_put_take = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end
local trapped_chest_mesecons_rules = mesecon.rules.pplate local trapped_chest_mesecons_rules = mesecon.rules.pplate
-- To be called if a player closed a chest -- To be called if a player closed a chest
@ -122,6 +142,9 @@ minetest.register_node("mcl_chests:"..basename, {
end end
meta:from_table(meta2:to_table()) meta:from_table(meta2:to_table())
end, end,
allow_metadata_inventory_move = protection_check_move,
allow_metadata_inventory_take = protection_check_put_take,
allow_metadata_inventory_put = protection_check_put_take,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name().. minetest.log("action", player:get_player_name()..
" moves stuff in chest at "..minetest.pos_to_string(pos)) " moves stuff in chest at "..minetest.pos_to_string(pos))
@ -211,9 +234,15 @@ minetest.register_node("mcl_chests:"..basename.."_left", {
end end
meta:from_table(meta2:to_table()) meta:from_table(meta2:to_table())
end, end,
-- BEGIN OF LISTRING WORKAROUND allow_metadata_inventory_move = protection_check_move,
allow_metadata_inventory_take = protection_check_put_take,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == "input" then local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
-- BEGIN OF LISTRING WORKAROUND
elseif listname == "input" then
local inv = minetest.get_inventory({type="node", pos=pos}) local inv = minetest.get_inventory({type="node", pos=pos})
if inv:room_for_item("main", stack) then if inv:room_for_item("main", stack) then
return -1 return -1
@ -226,11 +255,11 @@ minetest.register_node("mcl_chests:"..basename.."_left", {
return 0 return 0
end end
end end
-- END OF LISTRING WORKAROUND
else else
return stack:get_count() return stack:get_count()
end end
end, end,
-- END OF LISTRING WORKAROUND
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name().. minetest.log("action", player:get_player_name()..
" moves stuff in chest at "..minetest.pos_to_string(pos)) " moves stuff in chest at "..minetest.pos_to_string(pos))
@ -326,9 +355,15 @@ minetest.register_node("mcl_chests:"..basename.."_right", {
end end
meta:from_table(meta2:to_table()) meta:from_table(meta2:to_table())
end, end,
-- BEGIN OF LISTRING WORKAROUND allow_metadata_inventory_move = protection_check_move,
allow_metadata_inventory_take = protection_check_put_take,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == "input" then local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
-- BEGIN OF LISTRING WORKAROUND
elseif listname == "input" then
local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "right") local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "right")
local other_inv = minetest.get_inventory({type="node", pos=other_pos}) local other_inv = minetest.get_inventory({type="node", pos=other_pos})
if other_inv:room_for_item("main", stack) then if other_inv:room_for_item("main", stack) then
@ -341,11 +376,11 @@ minetest.register_node("mcl_chests:"..basename.."_right", {
return 0 return 0
end end
end end
-- END OF LISTRING WORKAROUND
else else
return stack:get_count() return stack:get_count()
end end
end, end,
-- END OF LISTRING WORKAROUND
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name().. minetest.log("action", player:get_player_name()..
" moves stuff in chest at "..minetest.pos_to_string(pos)) " moves stuff in chest at "..minetest.pos_to_string(pos))
@ -738,7 +773,14 @@ for color, desc in pairs(boxtypes) do
minetest.add_item(pos, boxitem) minetest.add_item(pos, boxitem)
end end
end, end,
allow_metadata_inventory_move = protection_check_move,
allow_metadata_inventory_take = protection_check_put_take,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
end
-- Do not allow to place shulker boxes into shulker boxes -- Do not allow to place shulker boxes into shulker boxes
local group = minetest.get_item_group(stack:get_name(), "shulker_box") local group = minetest.get_item_group(stack:get_name(), "shulker_box")
if group == 0 or group == nil then if group == 0 or group == nil then

@ -53,6 +53,11 @@ minetest.register_node("mcl_flowerpots:flower_pot", {
groups = {dig_immediate=3, deco_block=1, attached_node=1, dig_by_piston=1, flower_pot=1}, groups = {dig_immediate=3, deco_block=1, attached_node=1, dig_by_piston=1, flower_pot=1},
sounds = mcl_sounds.node_sound_stone_defaults(), sounds = mcl_sounds.node_sound_stone_defaults(),
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
local name = clicker:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return
end
local item = clicker:get_wielded_item():get_name() local item = clicker:get_wielded_item():get_name()
for _, row in ipairs(flowers) do for _, row in ipairs(flowers) do
local flower = row[1] local flower = row[1]
@ -120,6 +125,11 @@ minetest.register_node("mcl_flowerpots:flower_pot_"..flower, {
groups = {dig_immediate=3, attached_node=1, dig_by_piston=1, not_in_creative_inventory=1, flower_pot=2}, groups = {dig_immediate=3, attached_node=1, dig_by_piston=1, not_in_creative_inventory=1, flower_pot=2},
sounds = mcl_sounds.node_sound_stone_defaults(), sounds = mcl_sounds.node_sound_stone_defaults(),
on_rightclick = function(pos, item, clicker) on_rightclick = function(pos, item, clicker)
local name = clicker:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return
end
minetest.add_item({x=pos.x, y=pos.y+0.5, z=pos.z}, flower_node) minetest.add_item({x=pos.x, y=pos.y+0.5, z=pos.z}, flower_node)
minetest.set_node(pos, {name="mcl_flowerpots:flower_pot"}) minetest.set_node(pos, {name="mcl_flowerpots:flower_pot"})
end, end,
@ -163,6 +173,14 @@ minetest.register_node("mcl_flowerpots:flower_pot_"..flower, {
groups = {dig_immediate=3, attached_node=1, dig_by_piston=1, not_in_creative_inventory=1, flower_pot=2}, groups = {dig_immediate=3, attached_node=1, dig_by_piston=1, not_in_creative_inventory=1, flower_pot=2},
sounds = mcl_sounds.node_sound_stone_defaults(), sounds = mcl_sounds.node_sound_stone_defaults(),
on_rightclick = function(pos, item, clicker) on_rightclick = function(pos, item, clicker)
local name = ""
if clicker:is_player() then
name = clicker:get_player_name()
end
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return
end
minetest.add_item({x=pos.x, y=pos.y+0.5, z=pos.z}, flower_node) minetest.add_item({x=pos.x, y=pos.y+0.5, z=pos.z}, flower_node)
minetest.set_node(pos, {name="mcl_flowerpots:flower_pot"}) minetest.set_node(pos, {name="mcl_flowerpots:flower_pot"})
end, end,

@ -60,7 +60,9 @@ end
-- --
local function allow_metadata_inventory_put(pos, listname, index, stack, player) local function allow_metadata_inventory_put(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0 return 0
end end
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -111,7 +113,9 @@ local function allow_metadata_inventory_move(pos, from_list, from_index, to_list
end end
local function allow_metadata_inventory_take(pos, listname, index, stack, player) local function allow_metadata_inventory_take(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0 return 0
end end
return stack:get_count() return stack:get_count()

@ -71,6 +71,33 @@ local def_hopper = {
end end
meta:from_table(meta2:to_table()) meta:from_table(meta2:to_table())
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return count
end
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name().. minetest.log("action", player:get_player_name()..
" moves stuff in mcl_hoppers at "..minetest.pos_to_string(pos)) " moves stuff in mcl_hoppers at "..minetest.pos_to_string(pos))
@ -230,6 +257,33 @@ local def_hopper_side = {
end end
meta:from_table(meta2:to_table()) meta:from_table(meta2:to_table())
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return count
end
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name().. minetest.log("action", player:get_player_name()..
" moves stuff in mcl_hoppers at "..minetest.pos_to_string(pos)) " moves stuff in mcl_hoppers at "..minetest.pos_to_string(pos))

@ -125,6 +125,11 @@ minetest.register_node("mcl_itemframes:item_frame",{
if not itemstack then if not itemstack then
return return
end end
local pname = clicker:get_player_name()
if minetest.is_protected(pos, pname) then
minetest.record_protection_violation(pos, pname)
return
end
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
drop_item(pos, node, meta) drop_item(pos, node, meta)
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -150,6 +155,33 @@ minetest.register_node("mcl_itemframes:item_frame",{
end end
return itemstack return itemstack
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return count
end
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end,
on_destruct = function(pos) on_destruct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)

@ -138,7 +138,10 @@ minetest.register_node("mcl_jukebox:jukebox", {
on_rightclick= function(pos, node, clicker, itemstack, pointed_thing) on_rightclick= function(pos, node, clicker, itemstack, pointed_thing)
if not clicker then return end if not clicker then return end
local cname = clicker:get_player_name() local cname = clicker:get_player_name()
if minetest.is_protected(pos, cname) then
minetest.record_protection_violation(pos, cname)
return
end
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
if not inv:is_empty("main") then if not inv:is_empty("main") then
@ -172,6 +175,33 @@ minetest.register_node("mcl_jukebox:jukebox", {
end end
return itemstack return itemstack
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return count
end
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
local name = digger:get_player_name() local name = digger:get_player_name()
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)

@ -376,6 +376,11 @@ minetest.override_item("mcl_end:ender_eye", {
-- Place eye of ender into end portal frame -- Place eye of ender into end portal frame
if pointed_thing.under and node.name == "mcl_portals:end_portal_frame" then if pointed_thing.under and node.name == "mcl_portals:end_portal_frame" then
local protname = user:get_player_name()
if minetest.is_protected(pointed_thing.under, protname) then
minetest.record_protection_violation(pointed_thing.under, protname)
return itemstack
end
minetest.set_node(pointed_thing.under, { name = "mcl_portals:end_portal_frame_eye", param2 = node.param2 }) minetest.set_node(pointed_thing.under, { name = "mcl_portals:end_portal_frame_eye", param2 = node.param2 })
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then

@ -120,6 +120,11 @@ minetest.register_node("3d_armor_stand:armor_stand", {
on_destruct = drop_armor, on_destruct = drop_armor,
-- Put piece of armor on armor stand, or take one away -- Put piece of armor on armor stand, or take one away
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local protname = clicker:get_player_name()
if minetest.is_protected(pos, protname) then
minetest.record_protection_violation(pos, protname)
return
end
-- Check if player wields armor -- Check if player wields armor
local name = itemstack:get_name() local name = itemstack:get_name()
local list local list
@ -177,7 +182,21 @@ minetest.register_node("3d_armor_stand:armor_stand", {
after_place_node = function(pos) after_place_node = function(pos)
minetest.add_entity(pos, "3d_armor_stand:armor_entity") minetest.add_entity(pos, "3d_armor_stand:armor_entity")
end, end,
allow_metadata_inventory_put = function(pos, listname, index, stack) allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
end
local def = stack:get_definition() or {} local def = stack:get_definition() or {}
local groups = def.groups or {} local groups = def.groups or {}
if groups[listname] then if groups[listname] then
@ -185,7 +204,7 @@ minetest.register_node("3d_armor_stand:armor_stand", {
end end
return 0 return 0
end, end,
allow_metadata_inventory_move = function(pos) allow_metadata_inventory_move = function()
return 0 return 0
end, end,
on_metadata_inventory_put = function(pos) on_metadata_inventory_put = function(pos)