From 147b8a59c239ec769ed24c9403198774be914526 Mon Sep 17 00:00:00 2001 From: Bram van den Heuvel Date: Tue, 10 Sep 2024 18:02:53 +0200 Subject: [PATCH] Only carve through ground nodes --- init.lua | 51 +++++++++++++++++++++++++----------------------- lua/register.lua | 6 +++--- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/init.lua b/init.lua index 894f5f0..ae7c561 100644 --- a/init.lua +++ b/init.lua @@ -486,27 +486,34 @@ function internal.mapgen(minp, maxp, blockseed, vm, va) -- they're in. local sva = VoxelArea(minp, maxp) local data = vm:get_data() + local ground = { [ minetest.CONTENT_AIR ] = false } internal.write_classified_node( - data, va, used_biomes, classified_nodes.ceilings, sva, "node_roof" + data, va, used_biomes, classified_nodes.ceilings, sva, "node_roof", + ground ) internal.write_classified_node( - data, va, used_biomes, classified_nodes.contents, sva, "node_air" + data, va, used_biomes, classified_nodes.contents, sva, "node_air", + ground ) internal.write_classified_node( - data, va, used_biomes, classified_nodes.floors, sva, "node_floor" + data, va, used_biomes, classified_nodes.floors, sva, "node_floor", + ground ) internal.write_classified_node( - data, va, used_biomes, classified_nodes.walls, sva, "node_wall" + data, va, used_biomes, classified_nodes.walls, sva, "node_wall", + ground ) -- Place floor decorations -- In case the dust has not been defined, place air nodes first internal.write_classified_node( - data, va, used_biomes, classified_nodes.floor_decos, sva, "node_air" + data, va, used_biomes, classified_nodes.floor_decos, sva, "node_air", + ground ) internal.write_classified_node( - data, va, used_biomes, classified_nodes.floor_decos, sva, "node_dust" + data, va, used_biomes, classified_nodes.floor_decos, sva, "node_dust", + ground ) local claimed_floor = internal.write_simple_floor_decorations( data, va, used_biomes, classified_nodes.floor_decos, sva @@ -514,7 +521,8 @@ function internal.mapgen(minp, maxp, blockseed, vm, va) -- Place ceiling decorations internal.write_classified_node( - data, va, used_biomes, classified_nodes.ceiling_decos, sva, "node_air" + data, va, used_biomes, classified_nodes.ceiling_decos, sva, "node_air", + ground ) local claimed_ceiling = internal.write_simple_ceiling_decorations( data, va, used_biomes, classified_nodes.ceiling_decos, sva @@ -533,21 +541,6 @@ function internal.mapgen(minp, maxp, blockseed, vm, va) vm:write_to_map() end --- Place items -function internal.place_node_on_data(data, i, name) - if name == nil then - return - end - - local node_id = minetest.get_content_id(name) - - if node_id == nil then - return - end - - data[i] = node_id -end - -- Register a new biome function internal.register_biome(biome) biome = internal.clean_biome_def(biome) @@ -606,7 +599,7 @@ function internal.verticality_noise_params() } end -function internal.write_classified_node(vm_data, va, used_biomes, classified_nodes, small_va, biome_key) +function internal.write_classified_node(vm_data, va, used_biomes, classified_nodes, small_va, biome_key, ground_content_nodes) local default_biome = internal.default_biome() local biome_to_id = {} @@ -635,7 +628,17 @@ function internal.write_classified_node(vm_data, va, used_biomes, classified_nod local content_id = biome_to_id[biome] if content_id ~= "" then - vm_data[va:index(pos.x, pos.y, pos.z)] = content_id + local vi = va:index(pos.x, pos.y, pos.z) + local vm_node = vm_data[vi] + + if ground_content_nodes[vm_node] == nil then + local name = minetest.get_name_from_content_id(content_id) + ground_content_nodes[vm_node] = minetest.registered_nodes[name].is_ground_content or true + end + + if ground_content_nodes[vm_node] then + vm_data[vi] = content_id + end end end end diff --git a/lua/register.lua b/lua/register.lua index d989cca..968d290 100644 --- a/lua/register.lua +++ b/lua/register.lua @@ -68,9 +68,9 @@ ns_caves.register_decoration({ deco_type = "simple", place_on = "ceiling", fill_ratio = 0.025, - decoration = "mcl_bamboo:bamboo_block", + decoration = "mcl_colorblocks:concrete_green", height = 3, - height_max = 16, + height_max = 7, }) ns_caves.register_decoration({ @@ -79,6 +79,6 @@ ns_caves.register_decoration({ fill_ratio = 0.025, decoration = "mcl_bamboo:bamboo_block", height = 3, - height_max = 16, + height_max = 7, })