check if target is protected before trying to break/place a node, so as not to trigger protection violations

This commit is contained in:
flux 2022-09-16 16:12:17 -07:00
parent b6c02ac8de
commit 0ae7e0db19
No known key found for this signature in database
GPG Key ID: 9333B27816848A15
1 changed files with 16 additions and 0 deletions

View File

@ -336,6 +336,14 @@ if pipeworks.enable_node_breaker then
masquerade_as_owner = true,
sneak = false,
act = function(virtplayer, pointed_thing)
local player_name = virtplayer:get_player_name()
if (
minetest.is_protected(pointed_thing.above, player_name) or
minetest.is_protected(pointed_thing.under, player_name)
) then
return
end
--local dname = "nodebreaker.act() "
local wieldstack = virtplayer:get_wielded_item()
local oldwieldstack = ItemStack(wieldstack)
@ -427,6 +435,14 @@ if pipeworks.enable_deployer then
masquerade_as_owner = true,
sneak = false,
act = function(virtplayer, pointed_thing)
local player_name = virtplayer:get_player_name()
if (
minetest.is_protected(pointed_thing.above, player_name) or
minetest.is_protected(pointed_thing.under, player_name)
) then
return
end
local wieldstack = virtplayer:get_wielded_item()
virtplayer:set_wielded_item((minetest.registered_items[wieldstack:get_name()] or {on_place=minetest.item_place}).on_place(wieldstack, virtplayer, pointed_thing) or wieldstack)
end,