mirror of
https://github.com/joe7575/techpack.git
synced 2024-08-21 05:34:07 +02:00
check protection when attempting to dig multiblocks
This commit is contained in:
parent
802e5f239d
commit
008c1a466d
@ -199,12 +199,19 @@ minetest.register_node("tubelib_addons1:fermenter", {
|
|||||||
|
|
||||||
-- the fermenter needs 'on_dig' to be able to remove the upper node
|
-- the fermenter needs 'on_dig' to be able to remove the upper node
|
||||||
on_dig = function(pos, node, player)
|
on_dig = function(pos, node, player)
|
||||||
|
local pos_above = vector.add(pos, vector.new(0, 1, 0))
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
|
||||||
|
if minetest.is_protected(pos, player_name) or minetest.is_protected(pos_above, player_name) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local meta = M(pos)
|
local meta = M(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if inv:is_empty("dst") and inv:is_empty("src") then
|
if inv:is_empty("dst") and inv:is_empty("src") then
|
||||||
State:on_dig_node(pos, node, player)
|
State:on_dig_node(pos, node, player)
|
||||||
tubelib.remove_node(pos)
|
tubelib.remove_node(pos)
|
||||||
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
|
minetest.remove_node(pos_above)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -263,11 +270,18 @@ minetest.register_node("tubelib_addons1:fermenter_defect", {
|
|||||||
|
|
||||||
-- the fermenter needs 'on_dig' to be able to remove the upper node
|
-- the fermenter needs 'on_dig' to be able to remove the upper node
|
||||||
on_dig = function(pos, node, puncher, pointed_thing)
|
on_dig = function(pos, node, puncher, pointed_thing)
|
||||||
|
local pos_above = vector.add(pos, vector.new(0, 1, 0))
|
||||||
|
local puncher_name = puncher:get_player_name()
|
||||||
|
|
||||||
|
if minetest.is_protected(pos, puncher_name) or minetest.is_protected(pos_above, puncher_name) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local meta = M(pos)
|
local meta = M(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if inv:is_empty("dst") and inv:is_empty("src") then
|
if inv:is_empty("dst") and inv:is_empty("src") then
|
||||||
minetest.node_dig(pos, node, puncher, pointed_thing)
|
minetest.node_dig(pos, node, puncher, pointed_thing)
|
||||||
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
|
minetest.remove_node(pos_above)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -194,13 +194,20 @@ minetest.register_node("tubelib_addons1:reformer", {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
-- the reformer needs 'on_dig' to be able to remove the upper node
|
-- the reformer needs 'on_dig' to be able to remove the upper node
|
||||||
on_dig = function(pos, node, puncher, pointed_thing)
|
on_dig = function(pos, node, puncher)
|
||||||
|
local pos_above = vector.add(pos, vector.new(0, 1, 0))
|
||||||
|
local player_name = puncher:get_player_name()
|
||||||
|
|
||||||
|
if minetest.is_protected(pos, player_name) or minetest.is_protected(pos_above, player_name) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local meta = M(pos)
|
local meta = M(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if inv:is_empty("dst") and inv:is_empty("src") then
|
if inv:is_empty("dst") and inv:is_empty("src") then
|
||||||
State:on_dig_node(pos, node, puncher)
|
State:on_dig_node(pos, node, puncher)
|
||||||
tubelib.remove_node(pos)
|
tubelib.remove_node(pos)
|
||||||
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
|
minetest.remove_node(pos_above)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -259,11 +266,18 @@ minetest.register_node("tubelib_addons1:reformer_defect", {
|
|||||||
|
|
||||||
-- the reformer needs 'on_dig' to be able to remove the upper node
|
-- the reformer needs 'on_dig' to be able to remove the upper node
|
||||||
on_dig = function(pos, node, puncher, pointed_thing)
|
on_dig = function(pos, node, puncher, pointed_thing)
|
||||||
|
local pos_above = vector.add(pos, vector.new(0, 1, 0))
|
||||||
|
local puncher_name = puncher:get_player_name()
|
||||||
|
|
||||||
|
if minetest.is_protected(pos, puncher_name) or minetest.is_protected(pos_above, puncher_name) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local meta = M(pos)
|
local meta = M(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if inv:is_empty("dst") and inv:is_empty("src") then
|
if inv:is_empty("dst") and inv:is_empty("src") then
|
||||||
minetest.node_dig(pos, node, puncher, pointed_thing)
|
minetest.node_dig(pos, node, puncher, pointed_thing)
|
||||||
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
|
minetest.remove_node(pos_above)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user