Skip to content

Commit 619b7db

Browse files
authored
Fix extrusion ignoring protection (#116)
This fixes issue #111.
1 parent 3d391a0 commit 619b7db

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

nodes/node_builders.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ minetest.register_node("digtron:builder", {
364364
local build_facing = tonumber(meta:get_int("build_facing"))
365365
local facing = minetest.get_node(pos).param2
366366
local buildpos = digtron.find_new_pos(pos, facing)
367+
local protection_bypass = minetest.check_player_privs(player, "protection_bypass")
367368

368369
if (buildpos[controlling_coordinate] + meta:get_int("offset")) % meta:get_int("period") ~= 0 then
369370
return 0
@@ -388,6 +389,18 @@ minetest.register_node("digtron:builder", {
388389
return built_count
389390
end
390391

392+
-- When extruding beyond the first node, we may be out of area
393+
-- explored by `DigtronLayout`. `can_build_to` is not able to
394+
-- distinguish unknown nodes from unprotected ones.
395+
-- We have to check for protection ourselves.
396+
if extrusion_count > 0 then
397+
if minetest.is_protected(buildpos, player:get_player_name()) and
398+
not protection_bypass
399+
then
400+
return built_count
401+
end
402+
end
403+
391404
local oldnode = minetest.get_node(buildpos)
392405

393406
if not digtron.config.uses_resources then

0 commit comments

Comments
 (0)