make lush caves use new structures api

This commit is contained in:
cora 2022-06-19 21:17:15 +02:00
parent 394eaa5db8
commit d52827de69
3 changed files with 43 additions and 65 deletions

View File

@ -51,10 +51,10 @@ local function dripleaf_grow(pos, node)
minetest.set_node(target,{name = "mcl_lush_caves:dripleaf_big"})
end
function mcl_lush_caves.makelake(pos,pr)
function mcl_lush_caves.makelake(pos,def,pr)
local p1 = vector.offset(pos,-5,-2,-5)
local p2 = vector.offset(pos,5,1,5)
local nn = minetest.find_nodes_in_area_under_air(p1,p2,{"group:material_stone","mcl_core:clay"})
local nn = minetest.find_nodes_in_area_under_air(p1,p2,{"group:material_stone","mcl_core:clay","mcl_lush_caves:moss"})
table.sort(nn,function(a, b)
return vector_distance_xz(pos, a) < vector_distance_xz(pos, b)
end)
@ -88,9 +88,10 @@ function mcl_lush_caves.makelake(pos,pr)
end
end
end
return true
end
function mcl_lush_caves.makeazaela(pos,pr)
function mcl_lush_caves.makeazaela(pos,def,pr)
local airup = minetest.find_nodes_in_area_under_air(vector.offset(pos,0,40,0),pos,{"mcl_core:dirt_with_grass"})
if #airup == 0 then
return end
@ -630,42 +631,47 @@ minetest.register_globalstep(function(dtime)
end
end)
local lushcaves = { "LushCaves", "LushCaves_underground", "LushCaves_ocean", "LushCaves_deep_ocean"}
mcl_structures.register_structure("clay_pool",{
place_on = {"group:material_stone","mcl_core:gravel","mcl_lush_caves:moss","mcl_core:clay"},
spawn_by = {"air"},
num_spawn_by = 1,
noise_params = {
offset = 0,
scale = 0.01,
spread = {x = 250, y = 250, z = 250},
seed = 78375213,
octaves = 5,
persist = 0.1,
flags = "absvalue",
},
flags = "all_floors",
y_max = -10,
biomes = lushcaves,
place_func = mcl_lush_caves.makelake,
})
local azaleas = {}
local az_limit = 500
local deco_id_makelake = minetest.get_decoration_id("mcl_biomes:lake_structblock")
local deco_id_makeazalea = minetest.get_decoration_id("mcl_biomes:azalea_structblock")
minetest.set_gen_notify({decoration=true}, { deco_id_makelake })
minetest.set_gen_notify({decoration=true}, { deco_id_makeazalea })
mcl_mapgen_core.register_generator("mcl_lush_caves", nil, function(minp, maxp, blockseed)
local gennotify = minetest.get_mapgen_object("gennotify")
local pr = PseudoRandom(blockseed + 15)
local az = false
for _, pos in pairs(gennotify["decoration#"..deco_id_makeazalea] or {}) do
local realpos = vector.offset(pos,0,-1,0)
local node = minetest.get_node(realpos)
if node and node.name == "mcl_lush_caves:azalea_structblock" then
minetest.remove_node(realpos)
for _,a in pairs(azaleas) do
if vector.distance(realpos,a) < az_limit then
az = true
end
mcl_structures.register_structure("azalea_tree",{
place_on = {"group:material_stone","mcl_core:gravel","mcl_lush_caves:moss","mcl_core:clay"},
spawn_by = {"air"},
num_spawn_by = 1,
fill_ratio = 0.15,
flags = "all_ceilings",
y_max =-10,
y_min = mcl_vars.mg_overworld_min + 15,
biomes = lushcaves,
place_func = function(pos,def,pr)
for _,a in pairs(azaleas) do
if vector.distance(pos,a) < az_limit then
return true
end
if not az and mcl_lush_caves.makeazaela(realpos) then
table.insert(azaleas,realpos)
az = true
if mcl_lush_caves.makeazalea(pos,def,pr) then
table.insert(azaleas,pos)
return true
end
end
end
for _, pos in pairs(gennotify["decoration#"..deco_id_makelake] or {}) do
local realpos = vector.offset(pos,0,1,0)
local node = minetest.get_node(realpos)
if node and node.name == "mcl_lush_caves:lake_structblock" then
minetest.remove_node(realpos)
mcl_lush_caves.makelake(realpos, pr)
end
end
end)
})

View File

@ -1,3 +1,3 @@
name = mcl_lush_caves
author = cora
depends = mcl_sounds, mesecons, mcl_mapgen_core
depends = mcl_sounds, mesecons, mcl_mapgen_core, mcl_structures

View File

@ -4401,34 +4401,6 @@ local function register_decorations()
fill_ratio = 0.1,
})
minetest.register_decoration({
name = "mcl_biomes:lake_structblock",
decoration = "mcl_lush_caves:lake_structblock",
deco_type = "simple",
place_on = {"group:material_stone","mcl_core:gravel","mcl_lush_caves:moss","mcl_core:clay"},
spawn_by = {"air"},
num_spawn_by = 2,
sidelen = 16,
fill_ratio = 1,
y_max = -10,
flags = "all_floors",
biomes = lushcaves,
})
minetest.register_decoration({
name = "mcl_biomes:azalea_structblock",
decoration = "mcl_lush_caves:azalea_structblock",
deco_type = "simple",
place_on = {"group:material_stone","mcl_core:gravel","mcl_lush_caves:moss","mcl_core:clay"},
spawn_by = {"air"},
num_spawn_by = 4,
y_min = -25,
y_max = -5,
sidelen = 16,
fill_ratio = 0.2,
flags = "all_ceilings",
biomes = lushcaves,
})
minetest.register_decoration({
decoration = "mcl_lush_caves:cave_vines",