forked from VoxeLibre/VoxeLibre
Fix kelp drops in coral reefs, move coral/seagrass decoration to mcl_ocean from 6000+ line mods/MAPGEN/mcl_biomes/init.lua, change coral structure decoration to intermediate node that gets replaced by the structure after removing kelp in the area
This commit is contained in:
parent
0012bdb71e
commit
b1124da94a
|
@ -1,5 +1,6 @@
|
|||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
local mod_doc = minetest.get_modpath("doc")
|
||||
local mod_mcl_structures = minetest.get_modpath("mcl_structures")
|
||||
|
||||
local corals = {
|
||||
{ "tube", S("Tube Coral Block"), S("Dead Tube Coral Block"), S("Tube Coral"), S("Dead Tube Coral"), S("Tube Coral Fan"), S("Dead Tube Coral Fan") },
|
||||
|
@ -71,6 +72,7 @@ end
|
|||
-- Sound for non-block corals
|
||||
local sounds_coral_plant = mcl_sounds.node_sound_leaves_defaults({footstep = mcl_sounds.node_sound_dirt_defaults().footstep})
|
||||
|
||||
|
||||
for c=1, #corals do
|
||||
local id = corals[c][1]
|
||||
local doc_desc_block = S("Coral blocks live in the oceans and need a water source next to them to survive. Without water, they die off.")
|
||||
|
@ -316,3 +318,197 @@ minetest.register_abm({
|
|||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local coral_min = OCEAN_MIN
|
||||
local coral_max = -10
|
||||
local warm_oceans = {
|
||||
"JungleEdgeM_ocean",
|
||||
"Jungle_deep_ocean",
|
||||
"Savanna_ocean",
|
||||
"MesaPlateauF_ocean",
|
||||
"Swampland_ocean",
|
||||
"Mesa_ocean",
|
||||
"Plains_ocean",
|
||||
"MesaPlateauFM_ocean",
|
||||
"MushroomIsland_ocean",
|
||||
"SavannaM_ocean",
|
||||
"JungleEdge_ocean",
|
||||
"MesaBryce_ocean",
|
||||
"Jungle_ocean",
|
||||
"Desert_ocean",
|
||||
"JungleM_ocean",
|
||||
"MangroveSwamp_ocean"
|
||||
}
|
||||
local coral_deco_nodes = {}
|
||||
local function register_coral_decos(ck)
|
||||
local c = corals[ck][1]
|
||||
local noise = {
|
||||
offset = -0.0085,
|
||||
scale = 0.002,
|
||||
spread = {x = 25, y = 120, z = 25},
|
||||
seed = 235,
|
||||
octaves = 5,
|
||||
persist = 1.8,
|
||||
lacunarity = 3.5,
|
||||
flags = "absvalue"
|
||||
}
|
||||
minetest.register_decoration({
|
||||
--deco_type = "schematic",
|
||||
deco_type = "simple",
|
||||
decoration = "mcl_ocean:deco_"..c.."_coral_schem_1",
|
||||
place_on = {"group:sand", "mcl_core:gravel", "mcl_mud:mud"},
|
||||
sidelen = 80,
|
||||
noise_params = noise,
|
||||
biomes = warm_oceans,
|
||||
y_min = coral_min,
|
||||
y_max = coral_max,
|
||||
--schematic = mod_mcl_structures .. "/schematics/mcl_structures_coral_" .. c .. "_1.mts",
|
||||
rotation = "random",
|
||||
flags = "all_floors,force_placement",
|
||||
})
|
||||
table.insert(coral_deco_nodes, "mcl_ocean:deco_"..c.."_coral_schem_1")
|
||||
minetest.register_node(":mcl_ocean:deco_"..c.."_coral_schem_1", {
|
||||
paramtype = "light",
|
||||
group = { coral_deco_root = 1, },
|
||||
tiles = { "mcl_ocean_"..c.."_coral_block.png" },
|
||||
schematic = minetest.read_schematic(mod_mcl_structures .. "/schematics/mcl_structures_coral_" .. c .. "_1.mts", {}),
|
||||
after_place = mcl_ocean.fix_kelp_below_structure
|
||||
})
|
||||
|
||||
minetest.register_decoration({
|
||||
--deco_type = "schematic",
|
||||
deco_type = "simple",
|
||||
decoration = "mcl_ocean:deco_"..c.."_coral_schem_2",
|
||||
place_on = {"group:sand", "mcl_core:gravel", "mcl_mud:mud"},
|
||||
noise_params = noise,
|
||||
sidelen = 80,
|
||||
biomes = warm_oceans,
|
||||
y_min = coral_min,
|
||||
y_max = coral_max,
|
||||
--schematic = mod_mcl_structures .. "/schematics/mcl_structures_coral_" .. c .. "_2.mts",
|
||||
rotation = "random",
|
||||
flags = "all_floors,force_placement",
|
||||
})
|
||||
table.insert(coral_deco_nodes, "mcl_ocean:deco_"..c.."_coral_schem_2")
|
||||
minetest.register_node(":mcl_ocean:deco_"..c.."_coral_schem_2", {
|
||||
paramtype = "light",
|
||||
group = { coral_deco_root = 1, },
|
||||
tiles = { "mcl_ocean_"..c.."_coral_block.png" },
|
||||
schematic = minetest.read_schematic(mod_mcl_structures .. "/schematics/mcl_structures_coral_" .. c .. "_2.mts", {}),
|
||||
after_place = mcl_ocean.fix_kelp_below_structure
|
||||
})
|
||||
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"mcl_ocean:" .. c .. "_coral_block"},
|
||||
sidelen = 16,
|
||||
fill_ratio = 3,
|
||||
y_min = coral_min,
|
||||
y_max = coral_max,
|
||||
decoration = "mcl_ocean:" .. c .. "_coral",
|
||||
biomes = warm_oceans,
|
||||
flags = "force_placement, all_floors",
|
||||
height = 1,
|
||||
height_max = 1,
|
||||
})
|
||||
minetest.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,
|
||||
})
|
||||
end
|
||||
function mcl_ocean.mapgen.register_corals()
|
||||
-- Coral Reefs
|
||||
for k, _ in pairs(corals) do
|
||||
register_coral_decos(k)
|
||||
end
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"group:sand", "mcl_core:gravel", "mcl_mud:mud"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = -0.0085,
|
||||
scale = 0.002,
|
||||
spread = {x = 25, y = 120, z = 25},
|
||||
seed = 235,
|
||||
octaves = 5,
|
||||
persist = 1.8,
|
||||
lacunarity = 3.5,
|
||||
flags = "absvalue"
|
||||
},
|
||||
y_min = coral_min,
|
||||
y_max = coral_max,
|
||||
decoration = "mcl_ocean:dead_brain_coral_block",
|
||||
biomes = warm_oceans,
|
||||
flags = "force_placement",
|
||||
height = 1,
|
||||
height_max = 1,
|
||||
place_offset_y = -1,
|
||||
})
|
||||
--rare CORAl
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
decoration = "mcl_ocean:deco_cora_coral_schem",
|
||||
place_on = {"group:sand", "mcl_core:gravel"},
|
||||
fill_ratio = 0.0001,
|
||||
sidelen = 80,
|
||||
biomes = warm_oceans,
|
||||
y_min = coral_min,
|
||||
y_max = coral_max,
|
||||
rotation = "random",
|
||||
flags = "place_center_x,place_center_z, force_placement",
|
||||
})
|
||||
table.insert(coral_deco_nodes, "mcl_ocean:deco_cora_coral_schem")
|
||||
minetest.register_node(":mcl_ocean:deco_cora_coral_schem", {
|
||||
paramtype = "light",
|
||||
group = { coral_deco_root = 1, },
|
||||
tiles = { "mcl_ocean_brain_coral_block.png" },
|
||||
schematic = minetest.read_schematic(mod_mcl_structures .. "/schematics/coral_cora.mts", {}),
|
||||
after_place = mcl_ocean.fix_kelp_below_structure
|
||||
})
|
||||
local SCHEM_DIRECTIONS = {"0", "90", "180", "270"}
|
||||
local function expand_schematic(pos, node)
|
||||
local node_def = minetest.registered_nodes[node.name] or {}
|
||||
local schematic = node_def.schematic
|
||||
if not schematic then return end
|
||||
|
||||
minetest.set_node(pos, {name = "mcl_core:water_source"})
|
||||
local dx = math.max(schematic.size.x, schematic.size.z)
|
||||
local dy = schematic.size.y
|
||||
local dz = dx
|
||||
local minp = vector.offset(pos, -math.floor(dx / 2) - 1, 0, -math.floor(dz / 2) - 1)
|
||||
local maxp = vector.offset(minp, dx + 1, dy - 1, dz + 1)
|
||||
mcl_ocean.kelp.remove_kelp_below_structure(minp, maxp)
|
||||
|
||||
-- Deterministic rotation
|
||||
local prn = minetest.hash_node_position(pos)
|
||||
prn = (prn * math.floor(prn / 1e6)) % 4 + 1
|
||||
|
||||
minetest.place_schematic(pos, schematic, SCHEM_DIRECTIONS[prn], {}, true, "place_center_x,place_center_z")
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Coral schematic decoration expansion ABM",
|
||||
nodenames = coral_deco_nodes,
|
||||
interval = 0.1,
|
||||
chance = 1,
|
||||
catch_up = false,
|
||||
action = expand_schematic,
|
||||
})
|
||||
minetest.register_lbm({
|
||||
label = "Coral schematic decoration expansion LBM",
|
||||
name = ":mcl_ocean:coral_deco_expansion",
|
||||
nodenames = coral_deco_nodes,
|
||||
run_at_every_load = true,
|
||||
action = expand_schematic,
|
||||
})
|
||||
end
|
||||
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
mcl_ocean = {}
|
||||
mcl_ocean = {
|
||||
mapgen = {}
|
||||
}
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
-- Prismarine (includes sea lantern)
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/prismarine.lua")
|
||||
dofile(modpath.."/prismarine.lua")
|
||||
|
||||
-- Corals
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/corals.lua")
|
||||
dofile(modpath.."/corals.lua")
|
||||
|
||||
-- Seagrass
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/seagrass.lua")
|
||||
dofile(modpath.."/seagrass.lua")
|
||||
|
||||
-- Kelp
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/kelp.lua")
|
||||
dofile(modpath.."/kelp.lua")
|
||||
|
||||
-- Sea Pickle
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/sea_pickle.lua")
|
||||
dofile(modpath.."/sea_pickle.lua")
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ mcl_ocean.kelp = kelp
|
|||
-- Once reach the maximum, kelp no longer grows.
|
||||
kelp.MIN_AGE = 0
|
||||
kelp.MAX_AGE = 25
|
||||
kelp.MAX_HEIGHT = 16
|
||||
|
||||
kelp.TICK = 0.2 -- Tick interval (in seconds) for updating kelp.
|
||||
|
||||
|
@ -195,6 +196,7 @@ function kelp.find_unsubmerged(pos, node, height)
|
|||
for i=1,height do
|
||||
walk_pos.y = y + i
|
||||
local walk_node = mt_get_node(walk_pos)
|
||||
if walk_node.name == "ignore" then break end
|
||||
if not kelp.is_submerged(walk_node) then
|
||||
return walk_pos, walk_node, height, i
|
||||
end
|
||||
|
@ -359,12 +361,21 @@ function kelp.surface_after_dig_node(pos, node)
|
|||
return mt_set_node(pos, {name=minetest.registered_nodes[node.name].node_dig_prediction})
|
||||
end
|
||||
|
||||
|
||||
local function detach_unsubmerged(pos)
|
||||
local node = mt_get_node(pos)
|
||||
|
||||
local dig_pos,_, height = kelp.find_unsubmerged(pos, node)
|
||||
local dig_pos,dig_node, height = kelp.find_unsubmerged(pos, node)
|
||||
if dig_pos then
|
||||
-- Schematics destroy kelp roots
|
||||
if mt_registered_nodes[dig_node.name].schematic then
|
||||
minetest.swap_node(pos, {
|
||||
name = minetest.registered_nodes[node.name].node_dig_prediction,
|
||||
param = node.param,
|
||||
param2 = 0,
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
mt_sound_play(mt_registered_nodes[node.name].sounds.dug, { gain = 0.5, pos = dig_pos }, true)
|
||||
kelp.detach_dig(dig_pos, pos, true, node, height)
|
||||
local new_age = kelp.roll_init_age()
|
||||
|
@ -372,6 +383,22 @@ local function detach_unsubmerged(pos)
|
|||
end
|
||||
end
|
||||
|
||||
function kelp.remove_kelp_below_structure(minp, maxp)
|
||||
local minp = vector.offset(minp, 0, -kelp.MAX_HEIGHT - 1, 0)
|
||||
local kelp_pos_list,_ = minetest.find_nodes_in_area(minp, maxp, {"group:kelp"})
|
||||
|
||||
for i = 1,#kelp_pos_list do
|
||||
local kelp_pos = kelp_pos_list[i]
|
||||
local kelp_node = minetest.get_node(kelp_pos)
|
||||
|
||||
minetest.swap_node(kelp_pos, {
|
||||
name = minetest.registered_nodes[kelp_node.name].node_dig_prediction,
|
||||
param = kelp_node.param,
|
||||
param2 = 0,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local function grow_kelp (pos)
|
||||
local node = mt_get_node(pos)
|
||||
local age = retrieve_age(pos)
|
||||
|
|
|
@ -149,3 +149,46 @@ end
|
|||
if mod_doc then
|
||||
doc.add_entry_alias("nodes", "mcl_ocean:seagrass_dirt", "craftitems", "mcl_ocean:seagrass")
|
||||
end
|
||||
|
||||
function mcl_ocean.mapgen.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 = {x = 100, y = 100, z = 100},
|
||||
seed = seed,
|
||||
octaves = 3,
|
||||
persist = 0.6,
|
||||
}
|
||||
|
||||
for s = 1, #surfaces do
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {surfaces[s]},
|
||||
sidelen = 16,
|
||||
noise_params = noise,
|
||||
biomes = biomes,
|
||||
y_min = DEEP_OCEAN_MIN,
|
||||
y_max = y_max,
|
||||
decoration = nodes[s],
|
||||
param2 = param2,
|
||||
param2_max = param2_max,
|
||||
place_offset_y = -1,
|
||||
flags = "force_placement",
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3390,47 +3390,8 @@ local function register_grass_decoration(grasstype, offset, scale, biomes)
|
|||
end
|
||||
end
|
||||
|
||||
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 = {x = 100, y = 100, z = 100},
|
||||
seed = seed,
|
||||
octaves = 3,
|
||||
persist = 0.6,
|
||||
}
|
||||
|
||||
for s = 1, #surfaces do
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {surfaces[s]},
|
||||
sidelen = 16,
|
||||
noise_params = noise,
|
||||
biomes = biomes,
|
||||
y_min = DEEP_OCEAN_MIN,
|
||||
y_max = y_max,
|
||||
decoration = nodes[s],
|
||||
param2 = param2,
|
||||
param2_max = param2_max,
|
||||
place_offset_y = -1,
|
||||
flags = "force_placement",
|
||||
})
|
||||
end
|
||||
end
|
||||
local register_seagrass_decoration = mcl_ocean.mapgen.register_seagrass_decoration
|
||||
local register_corals = mcl_ocean.mapgen.register_corals
|
||||
|
||||
local coral_min = OCEAN_MIN
|
||||
local coral_max = -10
|
||||
|
@ -3452,107 +3413,10 @@ local warm_oceans = {
|
|||
"JungleM_ocean",
|
||||
"MangroveSwamp_ocean"
|
||||
}
|
||||
local corals = {
|
||||
"brain",
|
||||
"horn",
|
||||
"bubble",
|
||||
"tube",
|
||||
"fire"
|
||||
}
|
||||
|
||||
local function register_coral_decos(ck)
|
||||
local c = corals[ck]
|
||||
local noise = {
|
||||
offset = -0.0085,
|
||||
scale = 0.002,
|
||||
spread = {x = 25, y = 120, z = 25},
|
||||
seed = 235,
|
||||
octaves = 5,
|
||||
persist = 1.8,
|
||||
lacunarity = 3.5,
|
||||
flags = "absvalue"
|
||||
}
|
||||
minetest.register_decoration({
|
||||
deco_type = "schematic",
|
||||
place_on = {"group:sand", "mcl_core:gravel", "mcl_mud:mud"},
|
||||
sidelen = 80,
|
||||
noise_params = noise,
|
||||
biomes = warm_oceans,
|
||||
y_min = coral_min,
|
||||
y_max = coral_max,
|
||||
schematic = mod_mcl_structures .. "/schematics/mcl_structures_coral_" .. c .. "_1.mts",
|
||||
rotation = "random",
|
||||
flags = "all_floors,force_placement",
|
||||
})
|
||||
minetest.register_decoration({
|
||||
deco_type = "schematic",
|
||||
place_on = {"group:sand", "mcl_core:gravel", "mcl_mud:mud"},
|
||||
noise_params = noise,
|
||||
sidelen = 80,
|
||||
biomes = warm_oceans,
|
||||
y_min = coral_min,
|
||||
y_max = coral_max,
|
||||
schematic = mod_mcl_structures .. "/schematics/mcl_structures_coral_" .. c .. "_2.mts",
|
||||
rotation = "random",
|
||||
flags = "all_floors,force_placement",
|
||||
})
|
||||
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"mcl_ocean:" .. c .. "_coral_block"},
|
||||
sidelen = 16,
|
||||
fill_ratio = 3,
|
||||
y_min = coral_min,
|
||||
y_max = coral_max,
|
||||
decoration = "mcl_ocean:" .. c .. "_coral",
|
||||
biomes = warm_oceans,
|
||||
flags = "force_placement, all_floors",
|
||||
height = 1,
|
||||
height_max = 1,
|
||||
})
|
||||
minetest.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,
|
||||
})
|
||||
end
|
||||
|
||||
local function register_decorations()
|
||||
-- Coral Reefs
|
||||
for k, _ in pairs(corals) do
|
||||
register_coral_decos(k)
|
||||
end
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"group:sand", "mcl_core:gravel", "mcl_mud:mud"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = -0.0085,
|
||||
scale = 0.002,
|
||||
spread = {x = 25, y = 120, z = 25},
|
||||
seed = 235,
|
||||
octaves = 5,
|
||||
persist = 1.8,
|
||||
lacunarity = 3.5,
|
||||
flags = "absvalue"
|
||||
},
|
||||
y_min = coral_min,
|
||||
y_max = coral_max,
|
||||
decoration = "mcl_ocean:dead_brain_coral_block",
|
||||
biomes = warm_oceans,
|
||||
flags = "force_placement",
|
||||
height = 1,
|
||||
height_max = 1,
|
||||
place_offset_y = -1,
|
||||
})
|
||||
register_corals()
|
||||
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
|
@ -3610,19 +3474,6 @@ local function register_decorations()
|
|||
height_max = 1,
|
||||
place_offset_y = -1,
|
||||
})
|
||||
--rare CORAl
|
||||
minetest.register_decoration({
|
||||
deco_type = "schematic",
|
||||
place_on = {"group:sand", "mcl_core:gravel"},
|
||||
fill_ratio = 0.0001,
|
||||
sidelen = 80,
|
||||
biomes = warm_oceans,
|
||||
y_min = coral_min,
|
||||
y_max = coral_max,
|
||||
schematic = mod_mcl_structures .. "/schematics/coral_cora.mts",
|
||||
rotation = "random",
|
||||
flags = "place_center_x,place_center_z, force_placement",
|
||||
})
|
||||
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
|
|
Loading…
Reference in New Issue