From 38c333981fb8cab03fa86a4cd6c9ea5116222385 Mon Sep 17 00:00:00 2001 From: kno10 Date: Thu, 24 Oct 2024 22:44:22 +0200 Subject: [PATCH] polishing --- mods/MAPGEN/mcl_mapgen_core/api.lua | 12 +++- mods/MAPGEN/vl_biomes/deco/corals.lua | 32 ++++----- mods/MAPGEN/vl_biomes/deco/kelp.lua | 72 +++++++++++++++++++ mods/MAPGEN/vl_biomes/deco/reeds.lua | 2 +- .../deco/{seagrass_kelp.lua => seagrass.lua} | 71 +----------------- mods/MAPGEN/vl_biomes/init.lua | 6 +- 6 files changed, 105 insertions(+), 90 deletions(-) create mode 100644 mods/MAPGEN/vl_biomes/deco/kelp.lua rename mods/MAPGEN/vl_biomes/deco/{seagrass_kelp.lua => seagrass.lua} (62%) diff --git a/mods/MAPGEN/mcl_mapgen_core/api.lua b/mods/MAPGEN/mcl_mapgen_core/api.lua index ca8727885..c474926f0 100644 --- a/mods/MAPGEN/mcl_mapgen_core/api.lua +++ b/mods/MAPGEN/mcl_mapgen_core/api.lua @@ -227,9 +227,15 @@ local function sort_decorations() if not deco_id then error("Failed to register decoration "..tostring(def.name).." - name not unique?") end - if def.gen_callback then - minetest.set_gen_notify({decoration = true}, {deco_id}) - gennotify_map["decoration#" .. deco_id] = def + if def.name then + deco_id = minetest.get_decoration_id(def.name) + if not deco_id then + error("Failed to register decoration "..tostring(def.name).." - name not unique?") + end + if def.gen_callback then + minetest.set_gen_notify({decoration = true}, {deco_id}) + gennotify_map["decoration#" .. deco_id] = def + end end end pending_decorations = nil -- as we will not run again diff --git a/mods/MAPGEN/vl_biomes/deco/corals.lua b/mods/MAPGEN/vl_biomes/deco/corals.lua index cfdec72c1..21c58881d 100644 --- a/mods/MAPGEN/vl_biomes/deco/corals.lua +++ b/mods/MAPGEN/vl_biomes/deco/corals.lua @@ -2,7 +2,9 @@ local mod_mcl_structures = minetest.get_modpath("mcl_structures") local coral_min = vl_biomes.OCEAN_MIN local coral_max = -10 -local warm_oceans = vl_biomes.by_water_temp.warm +local warm_oceans = table.copy(vl_biomes.by_water_temp.warm) +for _, v in ipairs(vl_biomes.by_water_temp.lukewarm) do table.insert(warm_oceans, v) end +--minetest.log("action", "Warm oceans: "..dump(warm_oceans,"")) -- Coral Reefs for _, c in ipairs({ "brain", "horn", "bubble", "tube", "fire" }) do @@ -27,6 +29,9 @@ for _, c in ipairs({ "brain", "horn", "bubble", "tube", "fire" }) do schematic = mod_mcl_structures .. "/schematics/mcl_structures_coral_" .. c .. "_1.mts", rotation = "random", flags = "all_floors,force_placement", + spawn_by = "mcl_core:water_source", + check_offset = 1, + num_spawn_by = 12, }) mcl_mapgen_core.register_decoration({ deco_type = "schematic", @@ -39,6 +44,9 @@ for _, c in ipairs({ "brain", "horn", "bubble", "tube", "fire" }) do schematic = mod_mcl_structures .. "/schematics/mcl_structures_coral_" .. c .. "_2.mts", rotation = "random", flags = "all_floors,force_placement", + spawn_by = "mcl_core:water_source", + check_offset = 1, + num_spawn_by = 12, }) mcl_mapgen_core.register_decoration({ @@ -52,20 +60,9 @@ for _, c in ipairs({ "brain", "horn", "bubble", "tube", "fire" }) do biomes = warm_oceans, flags = "force_placement, all_floors", height = 1, - height_max = 1, - }) - mcl_mapgen_core.register_decoration({ - deco_type = "simple", - place_on = {"mcl_ocean:horn_coral_block"}, - sidelen = 16, - fill_ratio = 7, - y_min = coral_min, - y_max = coral_max, - decoration = "mcl_ocean:" .. c .. "_coral_fan", - biomes = warm_oceans, - flags = "force_placement, all_floors", - height = 1, - height_max = 1, + spawn_by = "mcl_core:water_source", + check_offset = 1, + num_spawn_by = 12, }) end @@ -149,7 +146,7 @@ mcl_mapgen_core.register_decoration({ height_max = 1, place_offset_y = -1, }) ---rare CORAl easter egg +--rare CORAl easter egg (multicolored coral) mcl_mapgen_core.register_decoration({ deco_type = "schematic", place_on = {"group:sand", "mcl_core:gravel"}, @@ -161,5 +158,8 @@ mcl_mapgen_core.register_decoration({ schematic = mod_mcl_structures .. "/schematics/coral_cora.mts", rotation = "random", flags = "all_floors,force_placement", + spawn_by = "mcl_core:water_source", + check_offset = 1, + num_spawn_by = 12, }) diff --git a/mods/MAPGEN/vl_biomes/deco/kelp.lua b/mods/MAPGEN/vl_biomes/deco/kelp.lua new file mode 100644 index 000000000..f38b8de09 --- /dev/null +++ b/mods/MAPGEN/vl_biomes/deco/kelp.lua @@ -0,0 +1,72 @@ +-- TODO: move to mcl_ocean? +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", + spawn_by = "mcl_core:water_source", + check_offset = 1, + num_spawn_by = 9, + }) + end +end + +-- TODO: use temperature classes, also to control amount? +register_kelp_decoration(-0.5, 1, { + "ExtremeHillsM_ocean", + "ExtremeHills+_ocean", + "MegaTaiga_ocean", + "MegaSpruceTaiga_ocean", + "Plains_ocean", + "SunflowerPlains_ocean", + "Forest_ocean", + "FlowerForest_ocean", + "BirchForest_ocean", + "BirchForestM_ocean", + "RoofedForest_ocean", + "Swampland_ocean", + "Jungle_ocean", + "JungleM_ocean", + "JungleEdge_ocean", + "JungleEdgeM_ocean", + "MushroomIsland_ocean", + + "ExtremeHillsM_deep_ocean", + "ExtremeHills+_deep_ocean", + "MegaTaiga_deep_ocean", + "MegaSpruceTaiga_deep_ocean", + "Plains_deep_ocean", + "SunflowerPlains_deep_ocean", + "Forest_deep_ocean", + "FlowerForest_deep_ocean", + "BirchForest_deep_ocean", + "BirchForestM_deep_ocean", + "RoofedForest_deep_ocean", + "Swampland_deep_ocean", + "Jungle_deep_ocean", + "JungleM_deep_ocean", + "JungleEdge_deep_ocean", + "JungleEdgeM_deep_ocean", + "MushroomIsland_deep_ocean", +}) diff --git a/mods/MAPGEN/vl_biomes/deco/reeds.lua b/mods/MAPGEN/vl_biomes/deco/reeds.lua index 28042dc1a..62cef60ad 100644 --- a/mods/MAPGEN/vl_biomes/deco/reeds.lua +++ b/mods/MAPGEN/vl_biomes/deco/reeds.lua @@ -17,7 +17,7 @@ for _, biome in ipairs(vl_biomes.overworld_biomes) do decoration = "mcl_core:reeds", height = 1, height_max = 3, - spawn_by = {"mcl_core:water_source", "mcl_core:river_water_source", "group:frosted_ice"}, + spawn_by = {"mcl_core:water_source", "mclx_core:river_water_source", "group:frosted_ice"}, num_spawn_by = 1, biomes = {biome}, param2 = biome._mcl_foliage_palette_index diff --git a/mods/MAPGEN/vl_biomes/deco/seagrass_kelp.lua b/mods/MAPGEN/vl_biomes/deco/seagrass.lua similarity index 62% rename from mods/MAPGEN/vl_biomes/deco/seagrass_kelp.lua rename to mods/MAPGEN/vl_biomes/deco/seagrass.lua index e80bccbb1..91390ac92 100644 --- a/mods/MAPGEN/vl_biomes/deco/seagrass_kelp.lua +++ b/mods/MAPGEN/vl_biomes/deco/seagrass.lua @@ -27,6 +27,9 @@ local function register_seagrass_decoration(offset, scale, biomes) param2_max = 3, place_offset_y = -1, flags = "force_placement", + spawn_by = "mcl_core:water_source", + check_offset = 1, + num_spawn_by = 9, }) end end @@ -104,71 +107,3 @@ register_seagrass_decoration(0, 0.5, { "ColdTaiga_beach_water", "ExtremeHills_beach", }) - -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", - "MegaSpruceTaiga_ocean", - "Plains_ocean", - "SunflowerPlains_ocean", - "Forest_ocean", - "FlowerForest_ocean", - "BirchForest_ocean", - "BirchForestM_ocean", - "RoofedForest_ocean", - "Swampland_ocean", - "Jungle_ocean", - "JungleM_ocean", - "JungleEdge_ocean", - "JungleEdgeM_ocean", - "MushroomIsland_ocean", - - "ExtremeHillsM_deep_ocean", - "ExtremeHills+_deep_ocean", - "MegaTaiga_deep_ocean", - "MegaSpruceTaiga_deep_ocean", - "Plains_deep_ocean", - "SunflowerPlains_deep_ocean", - "Forest_deep_ocean", - "FlowerForest_deep_ocean", - "BirchForest_deep_ocean", - "BirchForestM_deep_ocean", - "RoofedForest_deep_ocean", - "Swampland_deep_ocean", - "Jungle_deep_ocean", - "JungleM_deep_ocean", - "JungleEdge_deep_ocean", - "JungleEdgeM_deep_ocean", - "MushroomIsland_deep_ocean", -}) diff --git a/mods/MAPGEN/vl_biomes/init.lua b/mods/MAPGEN/vl_biomes/init.lua index d9b2c8aee..bc965dce9 100644 --- a/mods/MAPGEN/vl_biomes/init.lua +++ b/mods/MAPGEN/vl_biomes/init.lua @@ -87,6 +87,7 @@ vl_biomes.register_biome = function(def) if def._ocean then local odef = def._ocean if odef._mcl_skycolor == nil then odef._mcl_skycolor = vl_biomes.ocean_skycolor end + if odef._mcl_water_temp == nil and def._mcl_water_temp then odef._mcl_water_temp = def._mcl_water_temp end if odef._mcl_water_temp == nil or odef._mcl_water_temp == "default" then odef._mcl_water_temp = "ocean" end if odef._mcl_waterfogcolor == nil then odef._mcl_waterfogcolor = waterfogcolor[odef._mcl_water_temp] end if odef.y_min == nil and not odef.min_pos then odef.y_min = vl_biomes.OCEAN_MIN end @@ -146,7 +147,7 @@ vl_biomes.register_biome = function(def) -- build a biome map based on water temperature if k == "_ocean" and sdef._mcl_water_temp then local temp = sdef._mcl_water_temp - if not vl_biomes.by_water_temp[temp] then vl_biomes.by_water_temp[temp] = {} end + if vl_biomes.by_water_temp[temp] == nil then vl_biomes.by_water_temp[temp] = {} end table.insert(vl_biomes.by_water_temp[temp], sdef.name) end end @@ -326,10 +327,11 @@ elseif mg_name ~= "v6" then dofile(modpath.."/deco/corals.lua") dofile(modpath.."/deco/fern.lua") dofile(modpath.."/deco/flowers.lua") + dofile(modpath.."/deco/kelp.lua") dofile(modpath.."/deco/mushrooms.lua") dofile(modpath.."/deco/pumpkin.lua") dofile(modpath.."/deco/reeds.lua") - dofile(modpath.."/deco/seagrass_kelp.lua") + dofile(modpath.."/deco/seagrass.lua") dofile(modpath.."/deco/snowy_dirt.lua") dofile(modpath.."/deco/sweet_berry.lua") dofile(modpath.."/deco/tallgrass.lua")