commit 42b7c9490b0b52a6ca7a3debc9efc5c1605697a4 Author: Eric Meehan Date: Tue Jul 7 13:15:54 2026 -0400 Initial commit diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..77cd8a4 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +protector diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..7b44840 --- /dev/null +++ b/init.lua @@ -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) diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..9887c45 --- /dev/null +++ b/mod.conf @@ -0,0 +1,4 @@ +name = protected_mapblock_grid +description = Places protector blocks at every 16-node mapblock corner +author = ermeehan +version = 1.0.0