1
0

fix: fix dupe airblock (#5)

Добавил проверку на права креатива у игрока при установке air блока.
Эта правка исключает дюп блоков воздуха.

Co-authored-by: Andrey Stepanov <standmit@yandex.ru>
Reviewed-on: MTSR/tech_additions#5
Reviewed-by: Koldun <koldun@noreply.git.minetestserver.ru>
Co-authored-by: Shepel Pavel <shepelpavel@mail.ru>
Co-committed-by: Shepel Pavel <shepelpavel@mail.ru>
This commit is contained in:
Shepel Pavel 2024-12-22 15:31:17 +03:00 committed by Koldun
parent 833a9549c8
commit 168180ea34

View File

@ -1,7 +1,19 @@
local S = minetest.get_translator("tech_additions")
local replace_allowed = {}
replace_allowed["air"] = true
replace_allowed["default:water_source"] = true
replace_allowed["default:water_flowing"] = true
replace_allowed["default:river_water_source"] = true
replace_allowed["default:river_water_flowing"] = true
local placeairblock = function ()
return function(itemstack, user, pointed_thing)
local name = user:get_player_name()
if not minetest.is_creative_enabled(name) then
return
end
local pos = user:getpos()
local dir = user:get_look_dir()
local distancefromplayer = 3
@ -10,12 +22,14 @@ local placeairblock = function ()
y = pos.y + 1 + (dir.y * 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)
if getPos.name == "air" or
getPos.name == "default:water_source" or
getPos.name == "default:water_flowing" or
getPos.name == "default:river_water_source" or
getPos.name == "default:river_water_flowing" then
if replace_allowed[getPos.name] then
minetest.set_node(new_pos, {name="tech_additions:air_block"})
end
end