Don't trim plants in protected areas

This commit is contained in:
Wuzzy 2019-10-24 20:03:51 +02:00
parent b644ee53b2
commit 4d7db960e8
2 changed files with 10 additions and 0 deletions

View File

@ -1047,6 +1047,11 @@ minetest.register_node(
groups = {snappy = 2, dig_immediate = 3, attached_node = 1, grass = 1, normal_grass = 1, green_grass = 1},
sounds = default.node_sound_leaves_defaults(),
on_rightclick = function(pos, node, player, itemstack)
if minetest.is_protected(pos, player:get_player_name()) and
not minetest.check_player_privs(player, "protection_bypass") then
minetest.record_protection_violation(pos, player:get_player_name())
return itemstack
end
-- Trim tall grass clump when rightclicked by shears
local name = itemstack:get_name()
if minetest.get_item_group(name, "shears") == 1 then

View File

@ -261,6 +261,11 @@ minetest.register_node(
groups = {snappy=3, handy=2, attached_node=1, not_in_craft_guide = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_leaves_defaults(),
on_rightclick = function(pos, node, player, itemstack)
if minetest.is_protected(pos, player:get_player_name()) and
not minetest.check_player_privs(player, "protection_bypass") then
minetest.record_protection_violation(pos, player:get_player_name())
return itemstack
end
-- Trim cotton when rightclicking with shears
if minetest.get_item_group(itemstack:get_name(), "shears") == 1 then
itemstack = trim_cotton(pos, node, player, itemstack)