diff --git a/cavegen.lua b/cavegen.lua index 72d9f30..9d02834 100644 --- a/cavegen.lua +++ b/cavegen.lua @@ -7,12 +7,25 @@ fun_caves.cave_noise_2 = {offset = 0, scale = 1, seed = -8402, spread = {x = 40, local cave_noise_3 = {offset = 15, scale = 10, seed = 3721, spread = {x = 40, y = 40, z = 40}, octaves = 3, persist = 1, lacunarity = 2} +local ground_nodes = {} +ground_nodes[minetest.get_content_id('default:stone')] = true +ground_nodes[minetest.get_content_id('default:desert_stone')] = true +ground_nodes[minetest.get_content_id('default:sandstone')] = true +ground_nodes[minetest.get_content_id('default:dirt')] = true +ground_nodes[minetest.get_content_id('default:sand')] = true +ground_nodes[minetest.get_content_id('default:dirt_with_grass')] = true +ground_nodes[minetest.get_content_id('default:dirt_with_snow')] = true +ground_nodes[minetest.get_content_id('default:dirt_with_dry_grass')] = true + + fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone) local csize = vector.add(vector.subtract(maxp, minp), 1) local map_max = {x = csize.x, y = csize.y + 2, z = csize.z} local map_min = {x = minp.x, y = minp.y - 1, z = minp.z} + local return_heightmap = false if not heightmap then + return_heightmap = true heightmap = {} end @@ -39,7 +52,7 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone) height = - max_depth local ivm2 = area:index(x, maxp.y + 8, z) for y = maxp.y + 8, minp.y - 8, -1 do - if data[ivm2] ~= node['air'] and data[ivm2] ~= node['ignore'] then + if ground_nodes[data[ivm2]] then height = (y < maxp.y + 8) and y or max_depth break end @@ -103,5 +116,9 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone) end end - return write, heightmap + if return_heightmap then + return write, heightmap + else + return write, nil + end end diff --git a/mapgen.lua b/mapgen.lua index 8213ee4..f1e47a9 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -388,8 +388,12 @@ local function generate(p_minp, p_maxp, seed) fun_caves.fortress(minp, maxp, data, area, node) write = true else - local write1, write2, write3 - write1, heightmap = fun_caves.cavegen(minp, maxp, data, area, node, heightmap, underzone) + local write1, write2, write3, h2 + write1, h2 = fun_caves.cavegen(minp, maxp, data, area, node, heightmap, underzone) + if h2 then + heightmap = h2 + end + write2, write_p2 = fun_caves.decogen(minp, maxp, data, p2data, area, node, heightmap, biome_ids, underzone) write3 = fun_caves.treegen(minp, maxp, data, p2data, area, node) write = write1 or write2 or write3