template specialization for param2

This commit is contained in:
kno10 2024-10-24 17:09:49 +02:00
parent ca5f2b51c6
commit 59f1c25296
32 changed files with 334 additions and 112 deletions

View File

@ -148,16 +148,39 @@ end
local pending_decorations = {}
local gennotify_map = {}
function mcl_mapgen_core.register_decoration(def, callback)
def = table.copy(def) -- defensive deep copy, needed for water lily
if def.gen_callback and not def.name then error("gen_callback requires a named decoration.") end
if callback then error("Callbacks have been redesigned.") end
-- customize foliage colors
if (def._mcl_foliage_palette_index or 0) > 0 then
if type(def.schematic) ~= "string" then error("Can currently only be used with file schematics.") end
-- Load the schema and apply foliage palette
local schem = minetest.read_schematic(def.schematic, {})
schem.name = def.schematic -- preserve the file name
local cache = {}
for _, node in ipairs(schem.data) do
local kind = cache[node.name]
if kind == nil then
local ndef = minetest.registered_nodes[node.name]
kind = ndef and (ndef.groups.foliage_palette and "color")
or (ndef.groups.foliage_palette_wallmounted and "colorwallmounted")
or false
cache[node.name] = kind
end
if kind == "color" then
node.param2 = def._mcl_foliage_palette_index
elseif kind == "colorwallmounted" then
node.param2 = def._mcl_foliage_palette_index * 8 + (node.param2 % 8)
end
end
def.schematic = schem
end
if pending_decorations == nil then
minetest.log("warning", "Decoration registered after mapgen core initialization: "..tostring(def.name))
minetest.register_decoration(def)
if def.gen_callback then
def.deco_id = minetest.get_decoration_id(def.name)
if not def.deco_id then
error("Failed to get the decoration id for "..tostring(key))
error("Failed to get the decoration id for "..tostring(def.name))
else
minetest.set_gen_notify({decoration = true}, {def.deco_id})
gennotify_map["decoration#" .. def.deco_id] = def
@ -177,6 +200,10 @@ local function sort_decorations()
local sc = string.split(def.schematic, "/")
name = string.format("%s:%04d", sc[#sc], i)
end
if not name and type(def.schematic) == "table" and def.schematic.name then
local sc = string.split(def.schematic.name, "/")
name = string.format("%s:%04d", sc[#sc], i)
end
if not name and type(def.schematic) == "table" and def.schematic.data then
name = ""
for _, v in ipairs(def.schematic.data) do
@ -193,18 +220,16 @@ local function sort_decorations()
table.sort(keys)
for _, key in ipairs(keys) do
local def = map[key]
if def.name and minetest.get_decoration_id(def.name) then
minetest.log("warning", "Decoration ID not unique: "..def.name)
end
local deco_id = minetest.register_decoration(def)
if not deco_id then
error("Failed to register decoration"..tostring(key))
error("Failed to register decoration "..tostring(def.name).." - name not unique?")
end
if def.gen_callback then
deco_id = minetest.get_decoration_id(def.name)
if not deco_id then
error("Failed to get the decoration id for "..tostring(key))
else
minetest.set_gen_notify({decoration = true}, {deco_id})
gennotify_map["decoration#" .. deco_id] = def
end
minetest.set_gen_notify({decoration = true}, {deco_id})
gennotify_map["decoration#" .. deco_id] = def
end
end
pending_decorations = nil -- as we will not run again

View File

@ -285,6 +285,7 @@ local function set_water_palette(minp,maxp,data2,area,nodes)
local biomemap = minetest.get_mapgen_object("biomemap")
if not biomemap then return end
local aream = VoxelArea(vector.new(minp.x, 0, minp.z), vector.new(maxp.x, 0, maxp.z))
-- FIXME: this relies on the voxelmanip already being written.
local nodes = minetest.find_nodes_in_area(minp, maxp, nodes)
local lvm_used = false
for n=1, #nodes do
@ -303,6 +304,7 @@ local function set_water_palette(minp,maxp,data2,area,nodes)
return lvm_used
end
--[[
local function set_seagrass_param2(minp,maxp,data2,area,nodes)
local nodes = minetest.find_nodes_in_area(minp, maxp, nodes)
local lvm_used = false
@ -313,6 +315,7 @@ local function set_seagrass_param2(minp,maxp,data2,area,nodes)
end
return lvm_used
end
]]
-- Below the bedrock, generate air/void
local function world_structure(vm, data, data2, emin, emax, area, minp, maxp, blockseed)
@ -367,17 +370,19 @@ local function world_structure(vm, data, data2, emin, emax, area, minp, maxp, bl
return lvm_used, lvm_used, deco, ores
end
--[[ replaced with decoration hack to replace grass nodes
local function block_fixes_grass(vm, data, data2, emin, emax, area, minp, maxp, blockseed)
-- Set param2 (=color) of nodes which use the grass colour palette.
return minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min and
set_grass_palette(minp,maxp,data2,area,{"group:grass_palette"})
end
end]]
--[[ replaced with schematic specialization per biome
local function block_fixes_foliage(vm, data, data2, emin, emax, area, minp, maxp, blockseed)
-- Set param2 (=color) of nodes which use the foliage colour palette.
return minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min and
set_foliage_palette(minp,maxp,data2,area,{"group:foliage_palette", "group:foliage_palette_wallmounted"})
end
end]]
local function block_fixes_water(vm, data, data2, emin, emax, area, minp, maxp, blockseed)
-- Set param2 (=color) of nodes which use the water colour palette.
@ -385,11 +390,13 @@ local function block_fixes_water(vm, data, data2, emin, emax, area, minp, maxp,
set_water_palette(minp,maxp,data2,area,{"group:water_palette"})
end
--[[ no longer necessary, we generate them with param2=3
local function block_fixes_seagrass(vm, data, data2, emin, emax, area, minp, maxp, blockseed)
-- Set param2 of seagrass to 3.
return minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min and
set_seagrass_param2(minp, maxp, data2, area, {"group:seagrass"})
end
]]
-- End block fixes:
local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed)
@ -412,10 +419,10 @@ mcl_mapgen_core.register_generator("world_structure", world_structure, nil, 1, t
mcl_mapgen_core.register_generator("end_fixes", end_basic, nil, 9999, true)
if mg_name ~= "v6" and mg_name ~= "singlenode" then
mcl_mapgen_core.register_generator("block_fixes_grass", block_fixes_grass, nil, 9999, true)
mcl_mapgen_core.register_generator("block_fixes_foliage", block_fixes_foliage, nil, 9999, true)
-- replaced with decoration hack: mcl_mapgen_core.register_generator("block_fixes_grass", block_fixes_grass, nil, 9999, true)
-- replaced with schema specialization: mcl_mapgen_core.register_generator("block_fixes_foliage", block_fixes_foliage, nil, 9999, true)
mcl_mapgen_core.register_generator("block_fixes_water", block_fixes_water, nil, 9999, true)
mcl_mapgen_core.register_generator("block_fixes_seagrass", block_fixes_seagrass, nil, 9999, true)
-- replaced with using param2=3 during generation mcl_mapgen_core.register_generator("block_fixes_seagrass", block_fixes_seagrass, nil, 9999, true)
end
if mg_name == "v6" then
@ -423,6 +430,7 @@ if mg_name == "v6" then
end
-- still needed?
--[[
minetest.register_lbm({
label = "Fix grass palette indexes", -- This LBM fixes any incorrect grass palette indexes.
name = "mcl_mapgen_core:fix_grass_palette_indexes",
@ -435,8 +443,9 @@ minetest.register_lbm({
minetest.swap_node(pos, node)
end
end
})
})]]
--[[ FIXME: not yet replaced
minetest.register_lbm({
label = "Fix foliage palette indexes", -- Set correct palette indexes of foliage in old mapblocks.
name = "mcl_mapgen_core:fix_foliage_palette_indexes",
@ -490,8 +499,10 @@ minetest.register_lbm({
end
end
})
]]--
--[[ No longer necessary? Ugly?
-- Can we get rid of this ugly hack?
--[[
-- We go outside x and y for where trees are placed next to a biome that has already been generated.
-- We go above maxp.y because trees can often get placed close to the top of a generated area and folliage may not
-- be coloured correctly.

View File

@ -107,5 +107,6 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_classic.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 4,
})

View File

@ -183,5 +183,6 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_classic.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 4,
})

View File

@ -45,6 +45,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_tree.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 12,
})
-- Melon

View File

@ -38,6 +38,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_tree.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 13,
})
-- Melon
mcl_mapgen_core.register_decoration({

View File

@ -47,6 +47,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_tree_2.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 12,
})
mcl_mapgen_core.register_decoration({
deco_type = "schematic",
@ -65,6 +66,7 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_bush_oak_leaves.mts",
flags = "place_center_x, place_center_z",
_mcl_foliage_palette_index = 12,
})
-- Melon
mcl_mapgen_core.register_decoration({

View File

@ -41,6 +41,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_tree.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 13,
})
mcl_mapgen_core.register_decoration({
@ -60,6 +61,7 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_bush_oak_leaves.mts",
flags = "place_center_x, place_center_z",
_mcl_foliage_palette_index = 13,
})
-- Melon

View File

@ -43,6 +43,7 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_birch.mts",
flags = "place_center_x, place_center_z",
_mcl_foliage_palette_index = 8,
})
mcl_mapgen_core.register_decoration({
deco_type = "schematic",
@ -65,4 +66,5 @@ mcl_mapgen_core.register_decoration({
rotation = "random",
spawn_by = "group:flower",
priority = 1550,
_mcl_foliage_palette_index = 8,
})

View File

@ -43,6 +43,7 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_birch_tall.mts",
flags = "place_center_x, place_center_z",
_mcl_foliage_palette_index = 8,
})
mcl_mapgen_core.register_decoration({
@ -66,4 +67,5 @@ mcl_mapgen_core.register_decoration({
rotation = "random",
spawn_by = "group:flower",
priority = 1550,
_mcl_foliage_palette_index = 8,
})

View File

@ -47,6 +47,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_dark_oak.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 7,
})
local ratio_mushroom = 0.0001

View File

@ -1,28 +1,62 @@
-- Large flowers
local function register_large_flower(name, biomes, seed, offset)
mcl_mapgen_core.register_decoration({
deco_type = "schematic",
schematic = {
size = vector.new(1, 2, 1),
data = {
{name = "mcl_flowers:" .. name },
{name = "mcl_flowers:" .. name .. "_top" },
local ndef = minetest.registered_nodes["mcl_flowers:"..name]
local has_param2 = ndef and ndef.groups.grass_palette
local tdef = minetest.registered_nodes["mcl_flowers:"..name]
local thas_param2 = tdef and tdef.groups.grass_palette
if has_param2 then
for b = 1, #biomes do
local param2 = minetest.registered_biomes[biomes[b]]._mcl_grass_palette_index
local tparam2 = thas_param2 and param2 or nil
mcl_mapgen_core.register_decoration({
deco_type = "schematic",
schematic = {
size = vector.new(1, 2, 1),
data = {
{name = "mcl_flowers:" .. name, param2 = param2 },
{name = "mcl_flowers:" .. name .. "_top", param2 = tparam2 },
},
},
place_on = {"group:grass_block_no_snow", "mcl_core:dirt"},
sidelen = 16,
noise_params = {
offset = offset,
scale = 0.01,
spread = vector.new(300, 300, 300),
seed = seed,
octaves = 5,
persist = 0.62,
},
y_min = 1,
y_max = vl_biomes.overworld_max,
biomes = {biomes[b]},
})
end
else
mcl_mapgen_core.register_decoration({
deco_type = "schematic",
schematic = {
size = vector.new(1, 2, 1),
data = {
{name = "mcl_flowers:" .. name },
{name = "mcl_flowers:" .. name .. "_top" },
},
},
},
place_on = {"group:grass_block_no_snow", "mcl_core:dirt"},
sidelen = 16,
noise_params = {
offset = offset,
scale = 0.01,
spread = vector.new(300, 300, 300),
seed = seed,
octaves = 5,
persist = 0.62,
},
y_min = 1,
y_max = vl_biomes.overworld_max,
biomes = biomes,
})
place_on = {"group:grass_block_no_snow", "mcl_core:dirt"},
sidelen = 16,
noise_params = {
offset = offset,
scale = 0.01,
spread = vector.new(300, 300, 300),
seed = seed,
octaves = 5,
persist = 0.62,
},
y_min = 1,
y_max = vl_biomes.overworld_max,
biomes = biomes,
})
end
end
register_large_flower("rose_bush", {"Forest"}, 9350, -0.008)
@ -34,23 +68,49 @@ register_large_flower("lilac", {"FlowerForest"}, 10600, 0.003)
register_large_flower("sunflower", {"SunflowerPlains"}, 2940, 0.01)
local function register_flower(name, biomes, seed, offset)
mcl_mapgen_core.register_decoration({
deco_type = "simple",
place_on = {"group:grass_block_no_snow", "mcl_core:dirt"},
sidelen = 16,
noise_params = {
offset = offset,
scale = 0.006,
spread = vector.new(100, 100, 100),
seed = seed,
octaves = 3,
persist = 0.6
},
y_min = 1,
y_max = vl_biomes.overworld_max,
biomes = biomes,
decoration = "mcl_flowers:" .. name,
})
local ndef = minetest.registered_nodes["mcl_flowers:"..name]
local has_param2 = ndef and ndef.groups.grass_palette
if has_param2 then
for b = 1, #biomes do
local param2 = minetest.registered_biomes[biomes[b]]._mcl_grass_palette_index
mcl_mapgen_core.register_decoration({
deco_type = "simple",
place_on = {"group:grass_block_no_snow", "mcl_core:dirt"},
sidelen = 16,
noise_params = {
offset = offset,
scale = 0.006,
spread = vector.new(100, 100, 100),
seed = seed,
octaves = 3,
persist = 0.6
},
y_min = 1,
y_max = vl_biomes.overworld_max,
biomes = {biomes[b]},
decoration = "mcl_flowers:" .. name,
param2 = param2
})
end
else
mcl_mapgen_core.register_decoration({
deco_type = "simple",
place_on = {"group:grass_block_no_snow", "mcl_core:dirt"},
sidelen = 16,
noise_params = {
offset = offset,
scale = 0.006,
spread = vector.new(100, 100, 100),
seed = seed,
octaves = 3,
persist = 0.6
},
y_min = 1,
y_max = vl_biomes.overworld_max,
biomes = biomes,
decoration = "mcl_flowers:" .. name,
})
end
end
local flower_biomes1 = {"Plains", "SunflowerPlains", "RoofedForest", "Forest", "BirchForest", "BirchForestM", "Taiga", "ColdTaiga", "Jungle", "JungleM", "JungleEdge", "JungleEdgeM", "Savanna", "SavannaM", "ExtremeHills", "ExtremeHillsM", "ExtremeHills+", "ExtremeHills+_snowtop"}

View File

@ -1,24 +1,30 @@
-- Sugar canes
mcl_mapgen_core.register_decoration({
deco_type = "simple",
place_on = {"mcl_core:dirt", "mcl_core:coarse_dirt", "group:grass_block_no_snow", "group:sand", "mcl_core:podzol", "mcl_core:reeds"},
sidelen = 16,
noise_params = {
offset = -0.3,
scale = 0.7,
spread = vector.new(200, 200, 200),
seed = 2,
octaves = 3,
persist = 0.7
},
y_min = 1,
y_max = vl_biomes.overworld_max,
decoration = "mcl_core:reeds",
height = 1,
height_max = 3,
spawn_by = {"mcl_core:water_source", "group:frosted_ice"}, -- TODO: river water source, too?
num_spawn_by = 1,
})
for _, biome in ipairs(vl_biomes.overworld_biomes) do
mcl_mapgen_core.register_decoration({
deco_type = "simple",
place_on = {"mcl_core:dirt", "mcl_core:coarse_dirt", "group:grass_block_no_snow", "group:sand", "mcl_core:podzol", "mcl_core:reeds"},
sidelen = 16,
noise_params = {
offset = -0.3,
scale = 0.7,
spread = vector.new(200, 200, 200),
seed = 2,
octaves = 3,
persist = 0.7
},
y_min = 1,
y_max = vl_biomes.overworld_max,
decoration = "mcl_core:reeds",
height = 1,
height_max = 3,
spawn_by = {"mcl_core:water_source", "mcl_core:river_water_source", "group:frosted_ice"},
num_spawn_by = 1,
biomes = {biome},
param2 = biome._mcl_foliage_palette_index
})
end
-- additional reeds in swamps
mcl_mapgen_core.register_decoration({
deco_type = "simple",
place_on = {"mcl_core:dirt", "mcl_core:coarse_dirt", "group:grass_block_no_snow", "group:sand", "mcl_core:podzol", "mcl_core:reeds"},
@ -39,5 +45,6 @@ mcl_mapgen_core.register_decoration({
height_max = 3,
spawn_by = {"mcl_core:water_source", "group:frosted_ice"},
num_spawn_by = 1,
param2 = 5 -- Swampland foliage palette index
})

View File

@ -1,41 +1,30 @@
-- TODO: move to mcl_ocean?
local function register_seagrass_decoration(grasstype, offset, scale, biomes)
local seed, nodes, surfaces, param2, param2_max, y_max
if grasstype == "seagrass" then
seed = 16
surfaces = {"mcl_core:dirt", "mcl_core:sand", "mcl_core:gravel", "mcl_core:redsand"}
nodes = {"mcl_ocean:seagrass_dirt", "mcl_ocean:seagrass_sand", "mcl_ocean:seagrass_gravel", "mcl_ocean:seagrass_redsand"}
y_max = 0
elseif grasstype == "kelp" then
seed = 32
param2 = 16
param2_max = 96
surfaces = {"mcl_core:dirt", "mcl_core:sand", "mcl_core:gravel"}
nodes = {"mcl_ocean:kelp_dirt", "mcl_ocean:kelp_sand", "mcl_ocean:kelp_gravel"}
y_max = -6
end
local noise = {
offset = offset,
scale = scale,
spread = vector.new(100, 100, 100),
seed = seed,
octaves = 3,
persist = 0.6,
}
-- TODO: move to mcl_ocean with a late registration (when biomes are registered)?
local function register_seagrass_decoration(offset, scale, biomes)
local surfaces = {"mcl_core:dirt", "mcl_core:sand", "mcl_core:gravel", "mcl_core:redsand"}
local nodes = {"mcl_ocean:seagrass_dirt", "mcl_ocean:seagrass_sand", "mcl_ocean:seagrass_gravel", "mcl_ocean:seagrass_redsand"}
for s = 1, #surfaces do
mcl_mapgen_core.register_decoration({
name = "Seagrass on "..surfaces[s],
deco_type = "simple",
priority = 1500,
place_on = {surfaces[s]},
sidelen = 16,
noise_params = noise,
noise_params = {
offset = offset,
scale = scale,
spread = vector.new(100, 100, 100),
seed = 16,
octaves = 3,
persist = 0.6,
},
biomes = biomes,
y_min = vl_biomes.DEEP_OCEAN_MIN,
y_max = y_max,
y_max = 0,
decoration = nodes[s],
param2 = param2,
param2_max = param2_max,
--param2 = 3, -- always use meshoption 3
param2 = 0,
param2_max = 3,
place_offset_y = -1,
flags = "force_placement",
})
@ -44,7 +33,7 @@ end
-- TODO: use temperature classes, rather than hardcoding biome lists here?
-- Also would allow for more/less seagrass depending on temperature class
register_seagrass_decoration("seagrass", 0, 0.5, {
register_seagrass_decoration(0, 0.5, {
"ColdTaiga_ocean",
"ExtremeHills_ocean",
"ExtremeHillsM_ocean",
@ -116,7 +105,37 @@ register_seagrass_decoration("seagrass", 0, 0.5, {
"ExtremeHills_beach",
})
register_seagrass_decoration("kelp", -0.5, 1, {
local function register_kelp_decoration(offset, scale, biomes)
local surfaces = {"mcl_core:dirt", "mcl_core:sand", "mcl_core:gravel"}
local nodes = {"mcl_ocean:kelp_dirt", "mcl_ocean:kelp_sand", "mcl_ocean:kelp_gravel"}
for s = 1, #surfaces do
mcl_mapgen_core.register_decoration({
name = "Kelp on "..surfaces[s],
deco_type = "simple",
priority = 1500,
place_on = {surfaces[s]},
sidelen = 16,
noise_params = {
offset = offset,
scale = scale,
spread = vector.new(100, 100, 100),
seed = 32,
octaves = 3,
persist = 0.6,
},
biomes = biomes,
y_min = vl_biomes.DEEP_OCEAN_MIN,
y_max = -6,
decoration = nodes[s],
param2 = 16,
param2_max = 96, -- height * 16
place_offset_y = -1,
flags = "force_placement",
})
end
end
register_kelp_decoration(-0.5, 1, {
"ExtremeHillsM_ocean",
"ExtremeHills+_ocean",
"MegaTaiga_ocean",

View File

@ -55,6 +55,7 @@ for i = 1, 4 do
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_large_"..i..".mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 7,
})
end
@ -77,6 +78,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_classic.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 7,
})
mcl_mapgen_core.register_decoration({
@ -100,6 +102,7 @@ mcl_mapgen_core.register_decoration({
rotation = "random",
spawn_by = "group:flower",
priority = 1550,
_mcl_foliage_palette_index = 7,
})
-- Rare balloon oak
@ -121,6 +124,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_balloon.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 7,
})
-- Birch
@ -141,6 +145,7 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_birch.mts",
flags = "place_center_x, place_center_z",
_mcl_foliage_palette_index = 7,
})
mcl_mapgen_core.register_decoration({
@ -164,5 +169,6 @@ mcl_mapgen_core.register_decoration({
rotation = "random",
spawn_by = "group:flower",
priority = 1550,
_mcl_foliage_palette_index = 7,
})

View File

@ -54,6 +54,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_classic.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 7,
})
mcl_mapgen_core.register_decoration({
@ -77,6 +78,7 @@ mcl_mapgen_core.register_decoration({
rotation = "random",
spawn_by = "group:flower",
priority = 1550,
_mcl_foliage_palette_index = 7,
})
-- Birch
@ -97,4 +99,5 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_birch.mts",
flags = "place_center_x, place_center_z",
_mcl_foliage_palette_index = 7,
})

View File

@ -34,6 +34,36 @@ local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superfl
-- Biomes by water temperature, for decorations and structures
vl_biomes.by_water_temp = {}
vl_biomes.overworld_biomes = {}
-- TODO: also add a list of nether and end biomes
-- Fix the grass color via decoration mechanism,
-- by replacing node_top with node_top and param2 set
-- TODO: this can be removed when param2 support to biomes is added
-- <https://github.com/minetest/minetest/issues/15319>
vl_biomes.fix_grass_color = function(def)
if (def._mcl_grass_palette_index or 0) == 0 then return end -- not necessary
-- for now, only support node_top.
local name = def.node_top
local ndef = minetest.registered_nodes[name]
if ndef and (ndef.groups.grass_palette or 0) ~= 0 and ndef.paramtype2 == "color" then -- no mixed types
local param2 = def._mcl_grass_palette_index
mcl_mapgen_core.register_decoration({
name = "Set "..name.." param2 in "..def.name,
priority = 10, -- run early to not modify other decorations
deco_type = "simple",
place_on = {name},
biomes = { def.name },
y_min = def.y_min or vl_biomes.overworld_min,
y_max = def.y_max or vl_biomes.overworld_max,
fill_ratio = 10, -- everything
decoration = name,
param2 = param2,
flags = "force_placement",
place_offset_y = -1, -- replace the node itself
})
end
end
-- Register a biome
-- This API has a few extensions over minetest.register_biome:
@ -121,10 +151,16 @@ vl_biomes.register_biome = function(def)
end
end
minetest.register_biome(def)
if is_overworld and def.y_max > 0 then table.insert(vl_biomes.overworld_biomes, def.name) end
vl_biomes.fix_grass_color(def)
-- minetest.log("action", "registering biome "..tostring(def.name))
for _, sdef in ipairs(subbiomes) do
-- minetest.log("action", "registering subbiome "..tostring(sdef.name))
minetest.register_biome(sdef)
if is_overworld and sdef.y_max > 0 then -- omit _ocean
table.insert(vl_biomes.overworld_biomes, sdef.name)
end
vl_biomes.fix_grass_color(sdef) -- usually a no-op
end
end
@ -148,6 +184,7 @@ function vl_biomes.register_spruce_decoration(seed, offset, sprucename, biomes,
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/" .. sprucename,
flags = "place_center_x, place_center_z",
-- not supported by spruceleaves: _mcl_foliage_palette_index = foliage_color,
})
end

View File

@ -47,6 +47,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_classic.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 12,
})
-- Huge jungle tree (4 variants)
@ -62,6 +63,7 @@ for i = 1, 4 do
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_tree_huge_"..i..".mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 12,
})
end
@ -77,6 +79,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_tree.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 12,
})
mcl_mapgen_core.register_decoration({
deco_type = "schematic",
@ -89,6 +92,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_tree_2.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 12,
})
mcl_mapgen_core.register_decoration({
deco_type = "schematic",
@ -101,6 +105,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_tree_3.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 12,
})
mcl_mapgen_core.register_decoration({
deco_type = "schematic",
@ -113,6 +118,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_tree_4.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 12,
})
-- Jungle bush
mcl_mapgen_core.register_decoration({
@ -132,6 +138,7 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_bush_oak_leaves.mts",
flags = "place_center_x, place_center_z",
_mcl_foliage_palette_index = 12,
})
mcl_mapgen_core.register_decoration({
deco_type = "schematic",
@ -150,6 +157,7 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_bush_oak_leaves_2.mts",
flags = "place_center_x, place_center_z",
_mcl_foliage_palette_index = 12,
})
-- Melon

View File

@ -38,6 +38,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_classic.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 13,
})
mcl_mapgen_core.register_decoration({
@ -51,6 +52,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_tree.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 13,
})
mcl_mapgen_core.register_decoration({
@ -70,6 +72,7 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_bush_oak_leaves.mts",
flags = "place_center_x, place_center_z",
_mcl_foliage_palette_index = 13,
})
-- Melon

View File

@ -47,6 +47,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_classic.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 12,
})
-- Huge jungle tree (4 variants)
@ -62,6 +63,7 @@ for i = 1, 4 do
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_tree_huge_"..i..".mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 12,
})
end
@ -76,6 +78,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_tree_2.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 12,
})
mcl_mapgen_core.register_decoration({
deco_type = "schematic",
@ -94,6 +97,7 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_bush_oak_leaves.mts",
flags = "place_center_x, place_center_z",
_mcl_foliage_palette_index = 12,
})
-- Melon
mcl_mapgen_core.register_decoration({

View File

@ -40,6 +40,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_classic.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 13,
})
mcl_mapgen_core.register_decoration({
@ -53,6 +54,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_tree.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 13,
})
mcl_mapgen_core.register_decoration({
@ -72,6 +74,7 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_bush_oak_leaves.mts",
flags = "place_center_x, place_center_z",
_mcl_foliage_palette_index = 13,
})
-- Lots of melons in Jungle Edge M

View File

@ -71,6 +71,7 @@ mcl_mapgen_core.register_decoration({
flags = "place_center_x, place_center_z, force_placement",
rotation = "random",
gen_callback = mangrove_root_gennotify,
_mcl_foliage_palette_index = 6,
})
mcl_mapgen_core.register_decoration({
name = "mcl_biomes:mangrove_tree_2",
@ -85,6 +86,7 @@ mcl_mapgen_core.register_decoration({
flags = "place_center_x, place_center_z, force_placement",
rotation = "random",
gen_callback = mangrove_root_gennotify,
_mcl_foliage_palette_index = 6,
})
mcl_mapgen_core.register_decoration({
name = "mcl_biomes:mangrove_tree_3",
@ -99,6 +101,7 @@ mcl_mapgen_core.register_decoration({
flags = "place_center_x, place_center_z, force_placement",
rotation = "random",
gen_callback = mangrove_root_gennotify,
_mcl_foliage_palette_index = 6,
})
mcl_mapgen_core.register_decoration({
name = "mcl_biomes:mangrove_tree_4",
@ -113,6 +116,7 @@ mcl_mapgen_core.register_decoration({
flags = "place_center_x, place_center_z, force_placement",
rotation = "random",
gen_callback = mangrove_root_gennotify,
_mcl_foliage_palette_index = 6,
})
mcl_mapgen_core.register_decoration({
name = "mcl_biomes:mangrove_tree_5",
@ -127,6 +131,7 @@ mcl_mapgen_core.register_decoration({
flags = "place_center_x, place_center_z, force_placement",
rotation = "random",
gen_callback = mangrove_root_gennotify,
_mcl_foliage_palette_index = 6,
})
mcl_mapgen_core.register_decoration({
name = "mcl_biomes:mangrove_bee_nest",
@ -151,6 +156,7 @@ mcl_mapgen_core.register_decoration({
spawn_by = "group:flower",
priority = 1550,
gen_callback = mangrove_root_gennotify,
_mcl_foliage_palette_index = 6,
})
mcl_mapgen_core.register_decoration({
deco_type = "simple",

View File

@ -40,12 +40,13 @@ mcl_mapgen_core.register_decoration({
place_on = {"group:grass_block_no_snow", "mcl_core:dirt"},
sidelen = 80,
fill_ratio = 0.0004,
biomes = {"JungleEdge", "JungleEdgeM", "Savanna"},
biomes = {"Savanna"},
y_min = 1,
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_classic.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 3,
})
-- Acacia (many variants)
for a = 1, 7 do
@ -60,6 +61,7 @@ for a = 1, 7 do
schematic = mod_mcl_core .. "/schematics/mcl_core_acacia_" .. a .. ".mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 3,
})
end

View File

@ -40,6 +40,7 @@ for a = 1, 7 do
schematic = mod_mcl_core .. "/schematics/mcl_core_acacia_" .. a .. ".mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 3,
})
end

View File

@ -51,6 +51,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_classic.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 2,
})
-- Rare spruce in Ice Plains
@ -71,6 +72,7 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_spruce_5.mts",
flags = "place_center_x, place_center_z",
-- not supported by spruce leaves _mcl_foliage_palette_index = 2,
})
-- Place tall grass on snow in Ice Plains
@ -93,9 +95,10 @@ mcl_mapgen_core.register_decoration({
schematic = {
size = vector.new(1, 2, 1),
data = {
{name = "mcl_core:dirt_with_grass", force_place = true, },
{name = "mcl_core:dirt_with_grass", force_place = true, param2 = 10 },
{name = "mcl_flowers:tallgrass", param2 = 10},
},
},
place_y_offset = -1,
})

View File

@ -74,6 +74,7 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_spruce_lollipop.mts",
flags = "place_center_x, place_center_z",
-- not supported by spruce leaves _mcl_foliage_palette_index = 2,
})
-- Matchstick spruce: Very few leaves, tall trunk
@ -94,10 +95,10 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_spruce_matchstick.mts",
flags = "place_center_x, place_center_z",
-- not supported by spruce leaves _mcl_foliage_palette_index = 2,
})
vl_biomes.register_spruce_decoration(11000, 0.00150, "mcl_core_spruce_5.mts", {"ColdTaiga"})
vl_biomes.register_spruce_decoration(2500, 0.00325, "mcl_core_spruce_1.mts", {"ColdTaiga"})
vl_biomes.register_spruce_decoration(7000, 0.00425, "mcl_core_spruce_3.mts", {"ColdTaiga"})
vl_biomes.register_spruce_decoration(9000, 0.00325, "mcl_core_spruce_4.mts", {"ColdTaiga"})

View File

@ -54,6 +54,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_swamp.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 5,
})
-- Lily pad
@ -75,7 +76,7 @@ for d = 1, lilydepth do
deco_type = "schematic",
schematic = {
size = vector.new(1, height, 1),
data = lily_schem,
data = table.copy(lily_schem),
},
place_on = "mcl_core:dirt",
sidelen = 16,

View File

@ -54,6 +54,7 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_spruce_lollipop.mts",
flags = "place_center_x, place_center_z",
-- not supported by spruce leaves _mcl_foliage_palette_index = 10,
})
-- Matchstick spruce: Very few leaves, tall trunk
@ -74,6 +75,7 @@ mcl_mapgen_core.register_decoration({
y_max = vl_biomes.overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_spruce_matchstick.mts",
flags = "place_center_x, place_center_z",
-- not supported by spruce leaves _mcl_foliage_palette_index = 10,
})
-- Common spruce

View File

@ -88,7 +88,6 @@ vl_biomes.register_spruce_decoration(3000, 0.0008, "mcl_core_spruce_huge_up_1.mt
vl_biomes.register_spruce_decoration(4000, 0.0008, "mcl_core_spruce_huge_up_2.mts", {"MegaTaiga"})
vl_biomes.register_spruce_decoration(6000, 0.0008, "mcl_core_spruce_huge_up_3.mts", {"MegaTaiga"})
-- Common spruce
vl_biomes.register_spruce_decoration(2500, 0.00325, "mcl_core_spruce_1.mts", {"MegaTaiga"})
vl_biomes.register_spruce_decoration(7000, 0.00425, "mcl_core_spruce_3.mts", {"MegaTaiga"})

View File

@ -59,6 +59,7 @@ for i = 1, 4 do
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_large_" .. i .. ".mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 11,
})
end
-- Small “classic” oak (many biomes)
@ -80,6 +81,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_classic.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 11,
})
-- Spruce
@ -87,3 +89,4 @@ vl_biomes.register_spruce_decoration(11000, 0.000025, "mcl_core_spruce_5.mts", {
vl_biomes.register_spruce_decoration(2500, 0.00005, "mcl_core_spruce_1.mts", {"ExtremeHills"})
vl_biomes.register_spruce_decoration(7000, 0.00005, "mcl_core_spruce_3.mts", {"ExtremeHills"})
vl_biomes.register_spruce_decoration(9000, 0.00005, "mcl_core_spruce_4.mts", {"ExtremeHills"})

View File

@ -58,6 +58,7 @@ for i = 1, 4 do
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_large_" .. i .. ".mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 11,
})
end
@ -80,6 +81,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_classic.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 11,
})
mcl_mapgen_core.register_decoration({
@ -100,6 +102,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_classic.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 11,
})
-- Spruce
@ -128,7 +131,7 @@ mcl_mapgen_core.register_decoration({
schematic = {
size = vector.new(1, 2, 1),
data = {
{name = "mcl_core:dirt_with_grass", force_place = true, },
{name = "mcl_core:dirt_with_grass", force_place = true, param2 = 8 },
{name = "mcl_flowers:tallgrass", param2 = 8},
},
},

View File

@ -62,6 +62,7 @@ for i = 1, 4 do
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_large_" .. i .. ".mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 11,
})
end
-- Small “classic” oak (many biomes)
@ -83,6 +84,7 @@ mcl_mapgen_core.register_decoration({
schematic = mod_mcl_core .. "/schematics/mcl_core_oak_classic.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
_mcl_foliage_palette_index = 11,
})
-- Spruce