MineClone5/mods/MAPGEN/mcl_debrisgen/init.lua

32 lines
1.1 KiB
Lua
Raw Normal View History

2021-08-05 02:01:07 +02:00
local minetest_find_nodes_in_area = minetest.find_nodes_in_area
local minetest_get_node = minetest.get_node
local minetest_set_node = minetest.set_node
local debris_name = "mcl_nether:ancient_debris"
local netherrack_name = "mcl_nether:netherrack"
local air_name = "air"
2021-07-25 02:34:55 +02:00
local min, max = mcl_mapgen.nether.min, mcl_mapgen.nether.max
2021-08-05 02:01:07 +02:00
mcl_mapgen.register_mapgen_block(function(minp, maxp)
local minp = minp
local minp_y = minp.y
if minp_y > max then return end
local maxp = maxp
local maxp_y = maxp.y
if maxp_y < min then return end
local nodes = minetest_find_nodes_in_area(minp, maxp, debris_name)
if nodes then
for _, pos in pairs(nodes) do
local x, y, z = pos.x, pos.y, pos.z
2022-03-13 23:59:21 +01:00
if minetest_get_node({x = x-1, y = y, z = z}).name == air_name
or minetest_get_node({x = x+1, y = y, z = z}).name == air_name
or minetest_get_node({x = x, y = y-1, z = z}).name == air_name
or minetest_get_node({x = x, y = y+1, z = z}).name == air_name
or minetest_get_node({x = x, y = y, z = z-1}).name == air_name
or minetest_get_node({x = x, y = y, z = z+1}).name == air_name then
minetest_set_node(pos, {name = netherrack_name})
2021-08-05 02:01:07 +02:00
end
end
end
end)