From 58bcc8a0e56927138151d911350606753a646de0 Mon Sep 17 00:00:00 2001 From: kno10 Date: Sat, 26 Oct 2024 19:04:10 +0200 Subject: [PATCH] Register only one decoration per grass color for tallgrass. --- mods/MAPGEN/vl_biomes/deco/tallgrass.lua | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/mods/MAPGEN/vl_biomes/deco/tallgrass.lua b/mods/MAPGEN/vl_biomes/deco/tallgrass.lua index d5d6a43c2..aded5cb10 100644 --- a/mods/MAPGEN/vl_biomes/deco/tallgrass.lua +++ b/mods/MAPGEN/vl_biomes/deco/tallgrass.lua @@ -1,7 +1,16 @@ -- Template to register a grass decoration local function register_grass_decoration(offset, scale, biomes) + local bmap = {} for b = 1, #biomes do - local param2 = minetest.registered_biomes[biomes[b]]._mcl_grass_palette_index + if minetest.registered_biomes[biomes[b]] then -- ignore missing biomes + local param2 = minetest.registered_biomes[biomes[b]]._mcl_grass_palette_index or 0 + if not bmap[param2] then bmap[param2] = {} end + table.insert(bmap[param2], biomes[b]) + else + minetest.log("warning", "Biome not found: "..biomes[b]) + end + end + for param2, bs in pairs(bmap) do mcl_mapgen_core.register_decoration({ deco_type = "simple", rank = 1500, @@ -15,7 +24,7 @@ local function register_grass_decoration(offset, scale, biomes) octaves = 3, persist = 0.6 }, - biomes = { biomes[b] }, + biomes = bs, y_min = 1, y_max = vl_biomes.overworld_max, decoration = "mcl_flowers:tallgrass", @@ -53,8 +62,17 @@ register_grass_decoration(-0.03, 1, {"BambooJungle", "BambooJungleM", "BambooJun -- Doubletall grass registration helper local function register_doubletall_grass(offset, scale, biomes) + local bmap = {} for b = 1, #biomes do - local param2 = minetest.registered_biomes[biomes[b]]._mcl_grass_palette_index + if minetest.registered_biomes[biomes[b]] then -- ignore missing biomes + local param2 = minetest.registered_biomes[biomes[b]]._mcl_grass_palette_index or 0 + if not bmap[param2] then bmap[param2] = {} end + table.insert(bmap[param2], biomes[b]) + else + minetest.log("warning", "Biome not found: "..biomes[b]) + end + end + for param2, bs in pairs(bmap) do mcl_mapgen_core.register_decoration({ deco_type = "schematic", rank = 1500,