Initial commit

This commit is contained in:
2026-07-07 13:15:54 -04:00
commit 42b7c9490b
3 changed files with 40 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
protector
+35
View File
@@ -0,0 +1,35 @@
local function is_mapblock_grid_pos(pos)
return (pos.x % 16 == 0) and (pos.y % 16 == 0) and (pos.z % 16 == 0)
end
minetest.register_on_placenode(function(pos, newnode, placer)
if newnode.name ~= "protector:protect" then
return
end
if is_mapblock_grid_pos(pos) then
return
end
minetest.remove_node(pos)
if placer and placer:is_player() then
local player_name = placer:get_player_name()
if not minetest.is_creative_enabled(player_name) then
local refund = ItemStack("protector:protect")
local inv = placer:get_inventory()
if inv and inv:room_for_item("main", refund) then
inv:add_item("main", refund)
else
minetest.add_item(vector.offset(pos, 0, 1, 0), refund)
end
end
minetest.chat_send_player(
player_name,
"Protector placement failed: place only at coordinates divisible by 16."
)
end
end)
+4
View File
@@ -0,0 +1,4 @@
name = protected_mapblock_grid
description = Places protector blocks at every 16-node mapblock corner
author = ermeehan
version = 1.0.0