1
0
mirror of https://github.com/mt-mods/pipeworks.git synced 2024-12-27 19:30:26 +01:00

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

This commit is contained in:
fluxionary 2022-09-16 16:16:58 -07:00 committed by GitHub
parent b6c02ac8de
commit 65cea1e33c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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,