improve protaction against air_block

This commit is contained in:
Andrey Stepanov 2024-12-22 17:26:28 +05:00
parent 0b130ca0cc
commit d57c2524d8
Signed by: Koldun
GPG Key ID: 53DE683337F5D25F

View File

@ -3,6 +3,10 @@ local S = minetest.get_translator("tech_additions")
local placeairblock = function () local placeairblock = function ()
return function(itemstack, user, pointed_thing) return function(itemstack, user, pointed_thing)
local name = user:get_player_name() local name = user:get_player_name()
if not minetest.is_creative_enabled(name) then
return
end
local pos = user:getpos() local pos = user:getpos()
local dir = user:get_look_dir() local dir = user:get_look_dir()
local distancefromplayer = 3 local distancefromplayer = 3
@ -11,11 +15,13 @@ local placeairblock = function ()
y = pos.y + 1 + (dir.y * distancefromplayer), y = pos.y + 1 + (dir.y * distancefromplayer),
z = pos.z + (dir.z * distancefromplayer), z = pos.z + (dir.z * distancefromplayer),
} }
if minetest.is_protected(new_pos, name) then
minetest.record_protection_violation(new_pos, name)
return
end
local getPos = minetest.get_node(new_pos) local getPos = minetest.get_node(new_pos)
if
not minetest.is_protected(new_pos, name) and
minetest.is_creative_enabled(name)
then
if getPos.name == "air" or if getPos.name == "air" or
getPos.name == "default:water_source" or getPos.name == "default:water_source" or
getPos.name == "default:water_flowing" or getPos.name == "default:water_flowing" or
@ -25,7 +31,6 @@ local placeairblock = function ()
end end
end end
end end
end
minetest.register_node("tech_additions:air_block", { minetest.register_node("tech_additions:air_block", {
description = S("Air Block"), description = S("Air Block"),