Prevent cave generation in the air

pull/1/head
Bram van den Heuvel 2024-04-29 18:26:59 +02:00
parent d111364b0f
commit 2809346af8
1 changed files with 8 additions and 5 deletions

View File

@ -625,14 +625,17 @@ function internal.generate_caves(data, minp, maxp)
internal.humidity_noise_params(), bminp, bmaxp
)
local air = minetest.get_content_id("air")
-- Place blocks where necessary
internal.iter_3d_area(bminp, bmaxp, function (i, pos)
local function place(name)
if type(name) == "string" then
vmanip:set_index(
vmanip:pos_to_index(pos),
minetest.get_content_id(name)
)
local vi = vmanip:pos_to_index(pos)
if vmanip:get_index(vi) == air then
elseif type(name) == "string" then
vmanip:set_index(vi, minetest.get_content_id(name))
elseif type(name) == "nil" then
else
error("Inserted invalid type " .. type(name) .. " into voxelmanip array")