1
0
Fork 0

Check protection of certain nodes before push/pull

- The node directly in front of a piston (including air)

- The 'final' position of any connected nodes
This commit is contained in:
seventeenthShulker 2023-07-06 15:41:41 +02:00
parent 0637182697
commit 3e12b3c700
1 changed files with 8 additions and 0 deletions

View File

@ -207,6 +207,11 @@ local function are_protected(nodes, player_name)
end end
function mesecon.mvps_push(pos, dir, maximum, player_name, piston_pos) function mesecon.mvps_push(pos, dir, maximum, player_name, piston_pos)
-- check if the node in front of the piston is protected against player_name (to prevent replacing air)
if minetest.is_protected(pos, player_name) then
return false
end
return mesecon.mvps_push_or_pull(pos, dir, dir, maximum, player_name, piston_pos) return mesecon.mvps_push_or_pull(pos, dir, dir, maximum, player_name, piston_pos)
end end
@ -241,6 +246,9 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, player_name,
if (newpos[i].x == piston_pos.x) and (newpos[i].y == piston_pos.y) and (newpos[i].z == piston_pos.z) then if (newpos[i].x == piston_pos.x) and (newpos[i].y == piston_pos.y) and (newpos[i].z == piston_pos.z) then
return return
end end
if minetest.is_protected(newpos[i], player_name) then
return
end
if not is_available(newpos[i]) then if not is_available(newpos[i]) then
local available = false local available = false
for j in ipairs(nodes) do for j in ipairs(nodes) do