add protection checks

This commit is contained in:
TenPlus1 2018-05-31 18:13:05 +01:00
parent a2b9d8f4ef
commit 20f827f4fb
3 changed files with 17 additions and 2 deletions

View File

@ -31,6 +31,11 @@ local function place_beans(itemstack, placer, pointed_thing, plantname)
return def.on_rightclick(pt.under, under, placer, itemstack) return def.on_rightclick(pt.under, under, placer, itemstack)
end end
-- check for protection
if minetest.is_protected(pt.under, placer:get_player_name()) then
return
end
-- check if pointing at bean pole -- check if pointing at bean pole
if under.name ~= "farming:beanpole" then if under.name ~= "farming:beanpole" then
return return
@ -119,7 +124,7 @@ minetest.register_node("farming:beanpole", {
return def.on_rightclick(pt.under, under, placer, itemstack) return def.on_rightclick(pt.under, under, placer, itemstack)
end end
if minetest.is_protected(pt.under, placer:get_player_name()) then if minetest.is_protected(pt.above, placer:get_player_name()) then
return return
end end

View File

@ -31,6 +31,11 @@ local function place_cocoa(itemstack, placer, pointed_thing, plantname)
return return
end end
-- check for protection
if minetest.is_protected(pt.above, placer:get_player_name()) then
return
end
-- add the node and remove 1 item from the itemstack -- add the node and remove 1 item from the itemstack
minetest.set_node(pt.above, {name = plantname}) minetest.set_node(pt.above, {name = plantname})

View File

@ -26,6 +26,11 @@ local function place_grapes(itemstack, placer, pointed_thing, plantname)
return def.on_rightclick(pt.under, under, placer, itemstack) return def.on_rightclick(pt.under, under, placer, itemstack)
end end
-- check for protection
if minetest.is_protected(pt.under, placer:get_player_name()) then
return
end
-- check if pointing at trellis -- check if pointing at trellis
if under.name ~= "farming:trellis" then if under.name ~= "farming:trellis" then
return return
@ -114,7 +119,7 @@ minetest.register_node("farming:trellis", {
return def.on_rightclick(pt.under, under, placer, itemstack) return def.on_rightclick(pt.under, under, placer, itemstack)
end end
if minetest.is_protected(pt.under, placer:get_player_name()) then if minetest.is_protected(pt.above, placer:get_player_name()) then
return return
end end