further fixes and improvements.

This commit is contained in:
kno10 2024-08-26 00:00:11 +02:00
parent 201ba616fe
commit 7cde4976de
27 changed files with 249 additions and 306 deletions

View file

@ -26,11 +26,6 @@ local mod_mcl_crimson = minetest.get_modpath("mcl_crimson")
local mod_mcl_blackstone = minetest.get_modpath("mcl_blackstone") local mod_mcl_blackstone = minetest.get_modpath("mcl_blackstone")
local mod_mcl_mangrove = minetest.get_modpath("mcl_mangrove") local mod_mcl_mangrove = minetest.get_modpath("mcl_mangrove")
-- these are registered asynchronously
local deco_ids_fungus = {}
local deco_ids_trees = {}
local deco_id_chorus_plant
-- --
-- Register biomes -- Register biomes
-- --
@ -3528,6 +3523,36 @@ local function register_coral_decos(ck)
}) })
end end
--- Fix light for mushroom lights after generation
local function fix_light_8_gennotify(t, minp, maxp, blockseed)
for _, pos in ipairs(t) do
minetest.fix_light(vector.offset(pos, -8, -8, -8), vector.offset(pos, 8, 8, 8))
end
end
--- Grow mangrove roots after generation
local swamp_biome_id, swamp_shore_id
local function mangrove_root_gennotify(t, minp, maxp, blockseed)
for _, pos in ipairs(t) do
local nn = minetest.find_nodes_in_area(vector.offset(pos, -8, -1, -8), vector.offset(pos, 8, 0, 8), {"mcl_mangrove:mangrove_roots"})
if nn and #nn > 0 then
local pr = PcgRandom(blockseed + mg_seed + 38327)
for _, v in pairs(nn) do
local l = pr:next(2, 16)
local n = minetest.get_node(vector.offset(v, 0, -1, 0)).name
if minetest.get_item_group(n, "water") > 0 then
local wl = "mcl_mangrove:water_logged_roots"
if n:find("river") then wl = "mcl_mangrove:river_water_logged_roots" end
minetest.bulk_set_node(minetest.find_nodes_in_area(v, vector.offset(v, 0, -l, 0), {"group:water"}), {name = wl})
elseif n == "mcl_mud:mud" then
minetest.bulk_set_node(minetest.find_nodes_in_area(v, vector.offset(v, 0, -l, 0), {"mcl_mud:mud"}), {name = "mcl_mangrove:mangrove_mud_roots"})
elseif n == "air" then
minetest.bulk_set_node(minetest.find_nodes_in_area(v, vector.offset(v, 0, -l, 0), {"air"}), {name = "mcl_mangrove:mangrove_roots"})
end
end
end
end
end
local function register_decorations() local function register_decorations()
-- Coral Reefs -- Coral Reefs
for k, _ in pairs(corals) do for k, _ in pairs(corals) do
@ -3991,11 +4016,8 @@ local function register_decorations()
schematic = mod_mcl_mangrove .. "/schematics/mcl_mangrove_tree_1.mts", schematic = mod_mcl_mangrove .. "/schematics/mcl_mangrove_tree_1.mts",
flags = "place_center_x, place_center_z, force_placement", flags = "place_center_x, place_center_z, force_placement",
rotation = "random", rotation = "random",
}, function() gen_callback = mangrove_root_gennotify,
local f = minetest.get_decoration_id("mcl_biomes:mangrove_tree_1") })
table.insert(deco_ids_trees, f)
minetest.set_gen_notify({decoration = true}, {f})
end)
mcl_mapgen_core.register_decoration({ mcl_mapgen_core.register_decoration({
name = "mcl_biomes:mangrove_tree_2", name = "mcl_biomes:mangrove_tree_2",
deco_type = "schematic", deco_type = "schematic",
@ -4008,11 +4030,8 @@ local function register_decorations()
schematic = mod_mcl_mangrove .. "/schematics/mcl_mangrove_tree_2.mts", schematic = mod_mcl_mangrove .. "/schematics/mcl_mangrove_tree_2.mts",
flags = "place_center_x, place_center_z, force_placement", flags = "place_center_x, place_center_z, force_placement",
rotation = "random", rotation = "random",
}, function() gen_callback = mangrove_root_gennotify,
local f = minetest.get_decoration_id("mcl_biomes:mangrove_tree_2") })
table.insert(deco_ids_trees, f)
minetest.set_gen_notify({decoration = true}, {f})
end)
mcl_mapgen_core.register_decoration({ mcl_mapgen_core.register_decoration({
name = "mcl_biomes:mangrove_tree_3", name = "mcl_biomes:mangrove_tree_3",
deco_type = "schematic", deco_type = "schematic",
@ -4025,11 +4044,8 @@ local function register_decorations()
schematic = mod_mcl_mangrove .. "/schematics/mcl_mangrove_tree_3.mts", schematic = mod_mcl_mangrove .. "/schematics/mcl_mangrove_tree_3.mts",
flags = "place_center_x, place_center_z, force_placement", flags = "place_center_x, place_center_z, force_placement",
rotation = "random", rotation = "random",
}, function() gen_callback = mangrove_root_gennotify,
local f = minetest.get_decoration_id("mcl_biomes:mangrove_tree_3") })
table.insert(deco_ids_trees, f)
minetest.set_gen_notify({decoration = true}, {f})
end)
mcl_mapgen_core.register_decoration({ mcl_mapgen_core.register_decoration({
name = "mcl_biomes:mangrove_tree_4", name = "mcl_biomes:mangrove_tree_4",
deco_type = "schematic", deco_type = "schematic",
@ -4042,11 +4058,8 @@ local function register_decorations()
schematic = mod_mcl_mangrove .. "/schematics/mcl_mangrove_tree_4.mts", schematic = mod_mcl_mangrove .. "/schematics/mcl_mangrove_tree_4.mts",
flags = "place_center_x, place_center_z, force_placement", flags = "place_center_x, place_center_z, force_placement",
rotation = "random", rotation = "random",
}, function() gen_callback = mangrove_root_gennotify,
local f = minetest.get_decoration_id("mcl_biomes:mangrove_tree_4") })
table.insert(deco_ids_trees, f)
minetest.set_gen_notify({decoration = true}, {f})
end)
mcl_mapgen_core.register_decoration({ mcl_mapgen_core.register_decoration({
name = "mcl_biomes:mangrove_tree_5", name = "mcl_biomes:mangrove_tree_5",
deco_type = "schematic", deco_type = "schematic",
@ -4059,11 +4072,8 @@ local function register_decorations()
schematic = mod_mcl_mangrove .. "/schematics/mcl_mangrove_tree_5.mts", schematic = mod_mcl_mangrove .. "/schematics/mcl_mangrove_tree_5.mts",
flags = "place_center_x, place_center_z, force_placement", flags = "place_center_x, place_center_z, force_placement",
rotation = "random", rotation = "random",
}, function() gen_callback = mangrove_root_gennotify,
local f = minetest.get_decoration_id("mcl_biomes:mangrove_tree_5") })
table.insert(deco_ids_trees, f)
minetest.set_gen_notify({decoration = true}, {f})
end)
mcl_mapgen_core.register_decoration({ mcl_mapgen_core.register_decoration({
name = "mcl_biomes:mangrove_bee_nest", name = "mcl_biomes:mangrove_bee_nest",
deco_type = "schematic", deco_type = "schematic",
@ -4086,11 +4096,8 @@ local function register_decorations()
rotation = "random", rotation = "random",
spawn_by = "group:flower", spawn_by = "group:flower",
priority = 1550, priority = 1550,
}, function() gen_callback = mangrove_root_gennotify,
local f = minetest.get_decoration_id("mcl_biomes:mangrove_bee_nest") })
table.insert(deco_ids_trees, f)
minetest.set_gen_notify({decoration = true}, {f})
end)
mcl_mapgen_core.register_decoration({ mcl_mapgen_core.register_decoration({
deco_type = "simple", deco_type = "simple",
place_on = {"mcl_mud:mud"}, place_on = {"mcl_mud:mud"},
@ -4698,9 +4705,9 @@ local function register_decorations()
y_max = mcl_vars.mg_overworld_max, y_max = mcl_vars.mg_overworld_max,
decoration = "mcl_core:cactus", decoration = "mcl_core:cactus",
biomes = {"Desert", biomes = {"Desert",
"Mesa", "Mesa_sandlevel", "Mesa", "Mesa_sandlevel",
"MesaPlateauF", "MesaPlateauF_sandlevel", "MesaPlateauF", "MesaPlateauF_sandlevel",
"MesaPlateauFM", "MesaPlateauFM_sandlevel"}, "MesaPlateauFM", "MesaPlateauFM_sandlevel"},
height = 1, height = 1,
height_max = 3, height_max = 3,
spawn_by = "air", spawn_by = "air",
@ -4907,7 +4914,7 @@ local function register_decorations()
octaves = 4, octaves = 4,
persist = 0.6, persist = 0.6,
}, },
biomes = {"Jungle", }, biomes = {"Jungle" },
y_min = 3, y_min = 3,
y_max = mcl_vars.mg_overworld_max, y_max = mcl_vars.mg_overworld_max,
schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_bush_oak_leaves_2.mts", schematic = mod_mcl_core .. "/schematics/mcl_core_jungle_bush_oak_leaves_2.mts",
@ -5190,30 +5197,6 @@ local function register_decorations()
register_seagrass_decoration("seagrass", 0, 0.5, b_seagrass) register_seagrass_decoration("seagrass", 0, 0.5, b_seagrass)
register_seagrass_decoration("kelp", -0.5, 1, b_kelp) register_seagrass_decoration("kelp", -0.5, 1, b_kelp)
local b_sponge = {"Plains_deep_ocean", "SunflowerPlains_deep_ocean", "Forest_deep_ocean", "FlowerForest_deep_ocean", "BirchForest_deep_ocean", "BirchForestM_deep_ocean", "RoofedForest_deep_ocean", "Jungle_deep_ocean", "JungleM_deep_ocean", "JungleEdge_deep_ocean", "JungleEdgeM_deep_ocean", "MushroomIsland_deep_ocean", "Desert_deep_ocean", "Savanna_deep_ocean", "SavannaM_deep_ocean", "Mesa_deep_ocean", "MesaBryce_deep_ocean", "MesaPlateauF_deep_ocean", "MesaPlateauFM_deep_ocean"}
-- Wet Sponge
-- TODO: Remove this when we got ocean monuments
mcl_mapgen_core.register_decoration({
deco_type = "simple",
decoration = "mcl_sponges:sponge_wet",
biomes = b_sponge,
spawn_by = {"group:water"},
num_spawn_by = 1,
place_on = {"mcl_core:dirt", "mcl_core:sand", "mcl_core:gravel"},
sidelen = 16,
noise_params = {
offset = 0.00495,
scale = 0.006,
spread = vector.new(250, 250, 250),
seed = 999,
octaves = 3,
persist = 0.666
},
flags = "force_placement",
y_min = mcl_vars.mg_lava_overworld_max + 5,
y_max = -20,
})
-- Place tall grass on snow in Ice Plains and Extreme Hills+ -- Place tall grass on snow in Ice Plains and Extreme Hills+
mcl_mapgen_core.register_decoration({ mcl_mapgen_core.register_decoration({
deco_type = "schematic", deco_type = "schematic",
@ -5604,11 +5587,8 @@ local function register_dimension_decorations()
schematic = mod_mcl_crimson .. "/schematics/warped_fungus_1.mts", schematic = mod_mcl_crimson .. "/schematics/warped_fungus_1.mts",
size = vector.new(5, 11, 5), size = vector.new(5, 11, 5),
rotation = "random", rotation = "random",
}, function() gen_callback = fix_light_8_gennotify,
local f = minetest.get_decoration_id("mcl_biomes:warped_tree1") })
table.insert(deco_ids_fungus, f)
minetest.set_gen_notify({decoration = true}, {f})
end)
mcl_mapgen_core.register_decoration({ mcl_mapgen_core.register_decoration({
deco_type = "schematic", deco_type = "schematic",
name = "mcl_biomes:warped_tree2", name = "mcl_biomes:warped_tree2",
@ -5622,11 +5602,8 @@ local function register_dimension_decorations()
schematic = mod_mcl_crimson .. "/schematics/warped_fungus_2.mts", schematic = mod_mcl_crimson .. "/schematics/warped_fungus_2.mts",
size = vector.new(5, 6, 5), size = vector.new(5, 6, 5),
rotation = "random", rotation = "random",
}, function() gen_callback = fix_light_8_gennotify,
local f = minetest.get_decoration_id("mcl_biomes:warped_tree2") })
table.insert(deco_ids_fungus, f)
minetest.set_gen_notify({decoration = true}, {f})
end)
mcl_mapgen_core.register_decoration({ mcl_mapgen_core.register_decoration({
deco_type = "schematic", deco_type = "schematic",
name = "mcl_biomes:warped_tree3", name = "mcl_biomes:warped_tree3",
@ -5640,11 +5617,8 @@ local function register_dimension_decorations()
schematic = mod_mcl_crimson .. "/schematics/warped_fungus_3.mts", schematic = mod_mcl_crimson .. "/schematics/warped_fungus_3.mts",
size = vector.new(5, 12, 5), size = vector.new(5, 12, 5),
rotation = "random", rotation = "random",
}, function() gen_callback = fix_light_8_gennotify,
local f = minetest.get_decoration_id("mcl_biomes:warped_tree3") })
table.insert(deco_ids_fungus, f)
minetest.set_gen_notify({decoration = true}, {f})
end)
mcl_mapgen_core.register_decoration({ mcl_mapgen_core.register_decoration({
deco_type = "simple", deco_type = "simple",
place_on = {"mcl_crimson:warped_nylium", "mcl_crimson:twisting_vines"}, place_on = {"mcl_crimson:warped_nylium", "mcl_crimson:twisting_vines"},
@ -5703,11 +5677,8 @@ local function register_dimension_decorations()
schematic = mod_mcl_crimson .. "/schematics/crimson_fungus_1.mts", schematic = mod_mcl_crimson .. "/schematics/crimson_fungus_1.mts",
size = vector.new(5, 8, 5), size = vector.new(5, 8, 5),
rotation = "random", rotation = "random",
}, function() gen_callback = fix_light_8_gennotify,
local f = minetest.get_decoration_id("mcl_biomes:crimson_tree1") })
table.insert(deco_ids_fungus, f)
minetest.set_gen_notify({decoration = true}, {f})
end)
minetest.register_alias("mcl_biomes:crimson_tree", "mcl_biomes:crimson_tree1") -- legacy inconsistency, fixed 08/2024 minetest.register_alias("mcl_biomes:crimson_tree", "mcl_biomes:crimson_tree1") -- legacy inconsistency, fixed 08/2024
mcl_mapgen_core.register_decoration({ mcl_mapgen_core.register_decoration({
deco_type = "schematic", deco_type = "schematic",
@ -5722,11 +5693,8 @@ local function register_dimension_decorations()
schematic = mod_mcl_crimson .. "/schematics/crimson_fungus_2.mts", schematic = mod_mcl_crimson .. "/schematics/crimson_fungus_2.mts",
size = vector.new(5, 12, 5), size = vector.new(5, 12, 5),
rotation = "random", rotation = "random",
}, function() gen_callback = fix_light_8_gennotify,
local f = minetest.get_decoration_id("mcl_biomes:crimson_tree2") })
table.insert(deco_ids_fungus, f)
minetest.set_gen_notify({decoration = true}, {f})
end)
mcl_mapgen_core.register_decoration({ mcl_mapgen_core.register_decoration({
deco_type = "schematic", deco_type = "schematic",
name = "mcl_biomes:crimson_tree3", name = "mcl_biomes:crimson_tree3",
@ -5740,11 +5708,8 @@ local function register_dimension_decorations()
schematic = mod_mcl_crimson .. "/schematics/crimson_fungus_3.mts", schematic = mod_mcl_crimson .. "/schematics/crimson_fungus_3.mts",
size = vector.new(7, 13, 7), size = vector.new(7, 13, 7),
rotation = "random", rotation = "random",
}, function() gen_callback = fix_light_8_gennotify,
local f = minetest.get_decoration_id("mcl_biomes:crimson_tree3") })
table.insert(deco_ids_fungus, f)
minetest.set_gen_notify({decoration = true}, {f})
end)
mcl_mapgen_core.register_decoration({ mcl_mapgen_core.register_decoration({
deco_type = "simple", deco_type = "simple",
place_on = {"mcl_crimson:warped_nylium", "mcl_crimson:weeping_vines", "mcl_nether:netherrack"}, place_on = {"mcl_crimson:warped_nylium", "mcl_crimson:weeping_vines", "mcl_nether:netherrack"},
@ -5955,15 +5920,24 @@ local function register_dimension_decorations()
decoration = "mcl_end:chorus_flower", decoration = "mcl_end:chorus_flower",
height = 1, height = 1,
biomes = {"End", "EndMidlands", "EndHighlands", "EndBarrens", "EndSmallIslands"}, biomes = {"End", "EndMidlands", "EndHighlands", "EndBarrens", "EndSmallIslands"},
},function() gen_callback = function(t, minp, maxp, blockseed)
deco_id_chorus_plant = minetest.get_decoration_id("mcl_biomes:chorus_plant") local pr = PcgRandom(blockseed + mg_seed + 99682)
minetest.set_gen_notify({decoration = true}, {deco_id_chorus_plant}) for _, pos in ipairs(t) do
end) local x, y, z = pos.x, pos.y, pos.z
if x < -10 or x > 10 or z < -10 or z > 10 then
local realpos = vector.new(x, y + 1, z)
local node = minetest.get_node(realpos)
if node and node.name == "mcl_end:chorus_flower" then
mcl_end.grow_chorus_plant(realpos, node, pr)
end
end
end
end,
})
-- TODO: End cities -- TODO: End cities
end end
-- --
-- Detect mapgen to select functions -- Detect mapgen to select functions
-- --
@ -5991,74 +5965,4 @@ if mg_name ~= "singlenode" then
register_dimension_biomes() register_dimension_biomes()
register_dimension_ores() register_dimension_ores()
register_dimension_decorations() register_dimension_decorations()
-- Overworld decorations for v6 are handled in mcl_mapgen_core
local function mangrove_roots_gen(gennotify, pr)
for _, f in pairs(deco_ids_trees) do
for _, pos in ipairs(gennotify["decoration#" .. f] or {}) do
local nn = minetest.find_nodes_in_area(vector.offset(pos, -8, -1, -8), vector.offset(pos, 8, 0, 8), {"mcl_mangrove:mangrove_roots"})
for _, v in pairs(nn) do
local l = pr:next(2, 16)
local n = minetest.get_node(vector.offset(v, 0, -1, 0)).name
if minetest.get_item_group(n, "water") > 0 then
local wl = "mcl_mangrove:water_logged_roots"
if n:find("river") then
wl = "mcl_mangrove:river_water_logged_roots"
end
minetest.bulk_set_node(minetest.find_nodes_in_area(vector.offset(v, 0, 0, 0), vector.offset(v, 0, -l, 0), {"group:water"}), {name = wl})
elseif n == "mcl_mud:mud" then
minetest.bulk_set_node(minetest.find_nodes_in_area(vector.offset(v, 0, 0, 0), vector.offset(v, 0, -l, 0), {"mcl_mud:mud"}), {name = "mcl_mangrove:mangrove_mud_roots"})
elseif n == "air" then
minetest.bulk_set_node(minetest.find_nodes_in_area(vector.offset(v, 0, 0, 0), vector.offset(v, 0, -l, 0), {"air"}), {name = "mcl_mangrove:mangrove_roots"})
end
end
end
end
end
local function chorus_gen (gennotify, pr)
for _, pos in ipairs(gennotify["decoration#" .. deco_id_chorus_plant] or {}) do
local x, y, z = pos.x, pos.y, pos.z
if x < -10 or x > 10 or z < -10 or z > 10 then
local realpos = vector.new(x, y + 1, z)
local node = minetest.get_node(realpos)
if node and node.name == "mcl_end:chorus_flower" then
mcl_end.grow_chorus_plant(realpos, node, pr)
end
end
end
end
local function crimson_warped_gen(gennotify)
for _, f in pairs(deco_ids_fungus) do
for _, pos in ipairs(gennotify["decoration#" .. f] or {}) do
minetest.fix_light(vector.offset(pos, -8, -8, -8), vector.offset(pos, 8, 8, 8))
end
end
end
if deco_id_chorus_plant or deco_ids_fungus or deco_ids_trees then
mcl_mapgen_core.register_generator("chorus_grow", nil, function(minp, maxp, blockseed)
local gennotify = minetest.get_mapgen_object("gennotify")
local pr = PseudoRandom(blockseed + 14)
if not (maxp.y < mcl_vars.mg_overworld_min or minp.y > mcl_vars.mg_overworld_max) then
local biomemap = minetest.get_mapgen_object("biomemap")
local swamp_biome_id = minetest.get_biome_id("MangroveSwamp")
local swamp_shore_id = minetest.get_biome_id("MangroveSwamp_shore")
if biomemap and (table.indexof(biomemap, swamp_biome_id) ~= -1 or table.indexof(biomemap, swamp_shore_id) ~= -1) then
mangrove_roots_gen(gennotify, pr)
end
end
if not (maxp.y < mcl_vars.mg_end_min or minp.y > mcl_vars.mg_end_max) then
chorus_gen(gennotify, pr)
end
if not (maxp.y < mcl_vars.mg_nether_min or minp.y > mcl_vars.mg_nether_max) then
crimson_warped_gen(gennotify)
end
end)
end
end end

View file

@ -256,7 +256,7 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param)
-- If it failed again, tough luck! We stick with only 1 chest spawned. -- If it failed again, tough luck! We stick with only 1 chest spawned.
local lastRandom local lastRandom
local secondChance = true -- second chance is still available local secondChance = true -- second chance is still available
for i=1, totalChests do for _ = 1, totalChests do
local r = pr:next(1, totalChestSlots) local r = pr:next(1, totalChestSlots)
if r == lastRandom and secondChance then if r == lastRandom and secondChance then
-- Oops! Same slot selected. Try again. -- Oops! Same slot selected. Try again.

View file

@ -4,19 +4,7 @@ local log_timing = minetest.settings:get_bool("mcl_logging_mapgen_timing", false
local registered_generators = {} local registered_generators = {}
local lvm, nodes, param2 = 0, 0, 0 local lvm, nodes, param2 = 0, 0, 0
local function run_generators(minp, maxp, blockseed) local seed = minetest.get_mapgen_setting("seed")
if nodes == 0 then return end
for _, rec in ipairs(registered_generators) do
if rec.nf then
local gt1 = os.clock()
local p1, p2 = vector.copy(minp), vector.copy(maxp) -- defensive copies
rec.nf(p1, p2, blockseed)
if log_timing then
minetest.log("action", string.format("[mcl_mapgen_core] %-20s %s ... %s %8.2fms", rec.id, minetest.pos_to_string(minp), minetest.pos_to_string(maxp), (os.clock() - gt1)*1000))
end
end
end
end
minetest.register_on_generated(function(minp, maxp, blockseed) minetest.register_on_generated(function(minp, maxp, blockseed)
local t1 = os.clock() local t1 = os.clock()
@ -62,7 +50,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
minetest.log("action", string.format("[mcl_mapgen_core] %-20s %s ... %s %8.2fms", "set_data", minetest.pos_to_string(minp), minetest.pos_to_string(maxp), (os.clock() - gt1)*1000)) minetest.log("action", string.format("[mcl_mapgen_core] %-20s %s ... %s %8.2fms", "set_data", minetest.pos_to_string(minp), minetest.pos_to_string(maxp), (os.clock() - gt1)*1000))
end end
local gt1 = os.clock() local gt1 = os.clock()
if deco_table then if deco_table and #deco_table > 0 then
minetest.generate_decorations(vm,vector.new(minp.x,deco_table.min,minp.z),vector.new(maxp.x,deco_table.max,maxp.z)) minetest.generate_decorations(vm,vector.new(minp.x,deco_table.min,minp.z),vector.new(maxp.x,deco_table.max,maxp.z))
elseif deco_used then elseif deco_used then
minetest.generate_decorations(vm) minetest.generate_decorations(vm)
@ -71,7 +59,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
minetest.log("action", string.format("[mcl_mapgen_core] %-20s %s ... %s %8.2fms", "decorations", minetest.pos_to_string(minp), minetest.pos_to_string(maxp), (os.clock() - gt1)*1000)) minetest.log("action", string.format("[mcl_mapgen_core] %-20s %s ... %s %8.2fms", "decorations", minetest.pos_to_string(minp), minetest.pos_to_string(maxp), (os.clock() - gt1)*1000))
end end
local gt1 = os.clock() local gt1 = os.clock()
if ore_table then if ore_table and #ore_table > 0 then
minetest.generate_ores(vm,vector.new(minp.x,ore_table.min,minp.z),vector.new(maxp.x,ore_table.max,maxp.z)) minetest.generate_ores(vm,vector.new(minp.x,ore_table.min,minp.z),vector.new(maxp.x,ore_table.max,maxp.z))
elseif ore_used then elseif ore_used then
minetest.generate_ores(vm) minetest.generate_ores(vm)
@ -89,7 +77,18 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
end end
end end
run_generators(minp, maxp, blockseed) if nodes > 0 then
for _, rec in ipairs(registered_generators) do
if rec.nf then
local gt1 = os.clock()
local p1, p2 = vector.copy(minp), vector.copy(maxp) -- defensive copies
rec.nf(p1, p2, blockseed)
if log_timing then
minetest.log("action", string.format("[mcl_mapgen_core] %-20s %s ... %s %8.2fms", rec.id, minetest.pos_to_string(minp), minetest.pos_to_string(maxp), (os.clock() - gt1)*1000))
end
end
end
end
mcl_vars.add_chunk(minp) mcl_vars.add_chunk(minp)
if logging then if logging then
@ -147,15 +146,25 @@ end
-- later, because currently decoration blockseeds are incremented sequentially -- later, because currently decoration blockseeds are incremented sequentially
-- c.f., https://github.com/minetest/minetest/issues/14919 -- c.f., https://github.com/minetest/minetest/issues/14919
local pending_decorations = {} local pending_decorations = {}
local gennotify_map = {}
function mcl_mapgen_core.register_decoration(def, callback) 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
if pending_decorations == nil then if pending_decorations == nil then
minetest.log("warning", "Decoration registered after mapgen: "..tostring(def.name)) minetest.log("warning", "Decoration registered after mapgen core initialization: "..tostring(def.name))
minetest.register_decoration(def) minetest.register_decoration(def)
if callback ~= nil then callback() end 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))
else
minetest.set_gen_notify({decoration = true}, {def.deco_id})
gennotify_map["decoration#" .. def.deco_id] = def
end
end
return return
end end
def = table.copy(def) -- defensive deep copy, needed for water lily
def.callback = callback
table.insert(pending_decorations, def) table.insert(pending_decorations, def)
end end
local function sort_decorations() local function sort_decorations()
@ -183,9 +192,38 @@ local function sort_decorations()
end end
table.sort(keys) table.sort(keys)
for _, key in ipairs(keys) do for _, key in ipairs(keys) do
minetest.register_decoration(map[key]) local def = map[key]
if map[key].callback then map[key].callback() end local deco_id = minetest.register_decoration(def)
if not deco_id then
error("Failed to register decoration"..tostring(key))
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
end
end end
pending_decorations = nil -- as we will not run again pending_decorations = nil -- as we will not run again
end end
mcl_mapgen_core.register_generator("Gennotify callbacks", nil, function(minp, maxp, blockseed)
local pr = PcgRandom(blockseed + seed + 48214) -- constant seed offset
local gennotify = minetest.get_mapgen_object("gennotify")
for key, def in pairs(gennotify_map) do
local t = gennotify[key]
if t and #t > 0 then
-- Fisher-Yates shuffle, using pr
for i = 1, #t-1 do
local r = pr:next(i,#t)
t[i], t[r] = t[r], t[i]
end
def.gen_callback(t, minp, maxp, blockseed)
end
end
end)
minetest.register_on_mods_loaded(sort_decorations) minetest.register_on_mods_loaded(sort_decorations)

View file

@ -1,6 +1,4 @@
mcl_mapgen_core = {} mcl_mapgen_core = {}
local registered_generators = {}
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
@ -118,8 +116,6 @@ elseif mg_name == "fractal" then
mg_flags.caverns = true mg_flags.caverns = true
end end
local mg_flags_str = "" local mg_flags_str = ""
for k,v in pairs(mg_flags) do for k,v in pairs(mg_flags) do
if v == false then if v == false then
@ -211,12 +207,12 @@ end
local function set_layers(data, area, content_id, check, min, max, minp, maxp, pr) local function set_layers(data, area, content_id, check, min, max, minp, maxp, pr)
if maxp.y < min or minp.y > max then return false end if maxp.y < min or minp.y > max then return false end
local lvm_used = false local lvm_used = false
if check == nil then if not check then
for p_pos in area:iter(minp.x, math.max(min, minp.y), minp.z, maxp.x, math.min(max, maxp.y), maxp.z) do for p_pos in area:iter(minp.x, math.max(min, minp.y), minp.z, maxp.x, math.min(max, maxp.y), maxp.z) do
data[p_pos] = content_id data[p_pos] = content_id
lvm_used = true lvm_used = true
end end
elseif check and type(check) == "function" then elseif type(check) == "function" then
-- slow path, needs vector coordinates (bedrock uses y only) -- slow path, needs vector coordinates (bedrock uses y only)
for p_pos in area:iter(minp.x, math.max(min, minp.y), minp.z, maxp.x, math.min(max, maxp.y), maxp.z) do for p_pos in area:iter(minp.x, math.max(min, minp.y), minp.z, maxp.x, math.min(max, maxp.y), maxp.z) do
if check(area:position(p_pos), data[p_pos], pr) then if check(area:position(p_pos), data[p_pos], pr) then
@ -408,6 +404,7 @@ local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blocksee
end end
end end
end end
lvm_used = true -- light is broken otherwise
return lvm_used, false return lvm_used, false
end end
@ -416,7 +413,7 @@ mcl_mapgen_core.register_generator("end_fixes", end_basic, nil, 9999, true)
if mg_name ~= "v6" and mg_name ~= "singlenode" then 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_grass", block_fixes_grass, nil, 9999, true)
--mcl_mapgen_core.register_generator("block_fixes_foliage", block_fixes_foliage, nil, 9999, true) 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_water", block_fixes_water, nil, 9999, true)
mcl_mapgen_core.register_generator("block_fixes_seagrass", block_fixes_seagrass, nil, 9999, true) mcl_mapgen_core.register_generator("block_fixes_seagrass", block_fixes_seagrass, nil, 9999, true)
end end
@ -425,6 +422,7 @@ if mg_name == "v6" then
dofile(modpath.."/v6.lua") dofile(modpath.."/v6.lua")
end end
--[[
minetest.register_lbm({ minetest.register_lbm({
label = "Fix grass palette indexes", -- This LBM fixes any incorrect grass palette indexes. label = "Fix grass palette indexes", -- This LBM fixes any incorrect grass palette indexes.
name = "mcl_mapgen_core:fix_grass_palette_indexes", name = "mcl_mapgen_core:fix_grass_palette_indexes",
@ -493,7 +491,6 @@ minetest.register_lbm({
end end
}) })
--[[
-- We go outside x and y for where trees are placed next to a biome that has already been generated. -- 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 -- 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. -- be coloured correctly.

View file

@ -136,7 +136,7 @@ minetest.register_ore({
clust_num_ores = 58, clust_num_ores = 58,
clust_size = 7, clust_size = 7,
y_min = deepslate_min, y_min = deepslate_min,
y_max = deepslate_max, y_max = deepslate_max,
noise_params = { noise_params = {
offset = 0, offset = 0,
scale = 1, scale = 1,
@ -450,14 +450,15 @@ if minetest.settings:get_bool("mcl_generate_ores", true) then
ore_type = "scatter", ore_type = "scatter",
ore = "mcl_nether:ancient_debris", ore = "mcl_nether:ancient_debris",
wherein = ancient_debris_wherein, wherein = ancient_debris_wherein,
clust_scarcity = 25000, -- 0.004% chance clust_scarcity = 15000,
-- in MC it's 0.004% chance (~= scarcity 25000) but reports and experiments show that ancient debris is unreasonably hard to find in survival with that value
clust_num_ores = 3, clust_num_ores = 3,
clust_size = 3, clust_size = 3,
y_min = mcl_vars.mg_nether_min + 8, y_min = mcl_vars.mg_nether_min + 8,
y_max = mcl_vars.mg_nether_min + 22, y_max = mcl_vars.mg_nether_min + 22,
}) })
-- Rare spawn (below) -- Rare spawn (below)
minetest.register_ore({ minetest.register_ore({
ore_type = "scatter", ore_type = "scatter",
ore = "mcl_nether:ancient_debris", ore = "mcl_nether:ancient_debris",

View file

@ -1,7 +1,5 @@
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname)
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
local peaceful = minetest.settings:get_bool("only_peaceful_mobs", false)
local BLAZE_SPAWNER_MAX_LIGHT = 11 local BLAZE_SPAWNER_MAX_LIGHT = 11

View file

@ -96,9 +96,7 @@ vl_structures.register_structure("end_shrine",{
filenames = { filenames = {
minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_portal_room_simple.mts" minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_portal_room_simple.mts"
}, },
after_place = function(pos,def,pr,p1,p2,size,rotation) after_place = function(pos, def, pr, p1, p2, size, rotation)
local p1 = vector.subtract(pos,size)
local p2 = vector.add(pos,size)
local spawners = minetest.find_nodes_in_area(p1, p2, "mcl_mobspawners:spawner") local spawners = minetest.find_nodes_in_area(p1, p2, "mcl_mobspawners:spawner")
for s=1, #spawners do for s=1, #spawners do
--local meta = minetest.get_meta(spawners[s]) --local meta = minetest.get_meta(spawners[s])

View file

@ -1,5 +1,4 @@
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname)
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
local function temple_placement_callback(pos,def,pr,p1,p2) local function temple_placement_callback(pos,def,pr,p1,p2)
@ -34,7 +33,7 @@ vl_structures.register_structure("desert_temple",{
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
y_offset = -12, y_offset = -12,
prepare = { padding = 3, corners = 3, foundation = true, clear = false }, prepare = { padding = 3, corners = 3, foundation = true, clear = false },
chunk_probability = 8, chunk_probability = 18,
y_max = mcl_vars.mg_overworld_max, y_max = mcl_vars.mg_overworld_max,
y_min = 1, y_min = 1,
biomes = { "Desert" }, biomes = { "Desert" },

View file

@ -1,5 +1,4 @@
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
--local S = minetest.get_translator(modname)
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
vl_structures.register_structure("desert_well",{ vl_structures.register_structure("desert_well",{

View file

@ -1,5 +1,4 @@
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname)
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
local spawnon = {"mcl_end:purpur_block"} local spawnon = {"mcl_end:purpur_block"}
@ -8,7 +7,7 @@ local function spawn_shulkers(pos,def,pr,p1,p2)
vl_structures.spawn_mobs("mobs_mc:shulker",spawnon,p1,p2,pr,1) vl_structures.spawn_mobs("mobs_mc:shulker",spawnon,p1,p2,pr,1)
local guard = minetest.find_nodes_in_area(p1,p2,{"mcl_itemframes:item_frame"}) local guard = minetest.find_nodes_in_area(p1,p2,{"mcl_itemframes:item_frame"})
if #guard > 0 then if #guard > 0 then
minetest.add_entity(vector.offset(guard[1],0,-1.5,0),"mobs_mc:shulker") minetest.add_entity(vector.offset(guard[1],0,-1.5,0),"mobs_mc:shulker") -- fixme: MCLA uses -0.5?
end end
end end

View file

@ -1,10 +1,9 @@
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname)
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
vl_structures.register_structure("end_spawn_obsidian_platform",{ vl_structures.register_structure("end_spawn_obsidian_platform",{
static_pos ={mcl_vars.mg_end_platform_pos}, static_pos ={mcl_vars.mg_end_platform_pos},
place_func = function(pos,def,pr) place_func = function(pos, _, _)
local obby = minetest.find_nodes_in_area(vector.offset(pos,-2,0,-2),vector.offset(pos,2,0,2),{"air","mcl_end:end_stone"}) local obby = minetest.find_nodes_in_area(vector.offset(pos,-2,0,-2),vector.offset(pos,2,0,2),{"air","mcl_end:end_stone"})
local air = minetest.find_nodes_in_area(vector.offset(pos,-2,1,-2),vector.offset(pos,2,3,2),{"air","mcl_end:end_stone"}) local air = minetest.find_nodes_in_area(vector.offset(pos,-2,1,-2),vector.offset(pos,2,3,2),{"air","mcl_end:end_stone"})
minetest.bulk_set_node(obby,{name="mcl_core:obsidian"}) minetest.bulk_set_node(obby,{name="mcl_core:obsidian"})
@ -41,7 +40,7 @@ vl_structures.register_structure("end_exit_portal_open",{
filenames = { filenames = {
modpath.."/schematics/mcl_structures_end_exit_portal.mts" modpath.."/schematics/mcl_structures_end_exit_portal.mts"
}, },
after_place = function(pos,def,pr,p1,p2) after_place = function(pos,def,pr,p1,p2)
minetest.fix_light(p1,p2) minetest.fix_light(p1,p2)
end end
}) })
@ -101,7 +100,7 @@ vl_structures.register_structure("end_spike",{
local h = d * pr:next(4,6) local h = d * pr:next(4,6)
local p1 = vector.offset(pos, -d / 2, 0, -d / 2) local p1 = vector.offset(pos, -d / 2, 0, -d / 2)
local p2 = vector.offset(pos, d / 2, h + d, d / 2) local p2 = vector.offset(pos, d / 2, h + d, d / 2)
minetest.emerge_area(p1, p2, function(blockpos, action, calls_remaining, param) minetest.emerge_area(p1, p2, function(_, _, calls_remaining)
if calls_remaining ~= 0 then return end if calls_remaining ~= 0 then return end
local s = make_endspike(pos,d,h) local s = make_endspike(pos,d,h)
minetest.set_node(vector.offset(s,0,1,0),{name="mcl_core:bedrock"}) minetest.set_node(vector.offset(s,0,1,0),{name="mcl_core:bedrock"})

View file

@ -1,13 +1,12 @@
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
--local S = minetest.get_translator(modname)
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
vl_structures.register_structure("fossil",{ vl_structures.register_structure("fossil",{
place_on = {"group:material_stone","group:sand"}, place_on = {"group:material_stone","group:sand"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
prepare = { }, prepare = { },
chunk_probability = 15, -- was 25 chunk_probability = 15, -- was 25, FIXME: needs rebalancing
y_offset = function(pr) return pr:next(-16,-32) end, y_offset = function(pr) return pr:next(-32,-16) end,
y_max = 15, y_max = 15,
y_min = mcl_vars.mg_overworld_min + 35, y_min = mcl_vars.mg_overworld_min + 35,
biomes = { "Desert" }, biomes = { "Desert" },

View file

@ -14,11 +14,11 @@ local function set_node_no_bedrock(pos, node)
return minetest.set_node(pos,node) return minetest.set_node(pos,node)
end end
local function makegeode(pos,def,pr) local function makegeode(pos, _, pr)
local size = pr:next(5,7) local size = pr:next(5,7)
local p1 = vector.offset(pos,-size,-size,-size) local p1 = vector.offset(pos,-size,-size,-size)
local p2 = vector.offset(pos,size,size,size) local p2 = vector.offset(pos,size,size,size)
minetest.emerge_area(p1, p2, function(blockpos, action, calls_remaining, param) minetest.emerge_area(p1, p2, function(_, _, calls_remaining)
if calls_remaining ~= 0 then return end if calls_remaining ~= 0 then return end
local calcite = {} local calcite = {}
local nn = minetest.find_nodes_in_area(p1,p2,{"group:material_stone","group:dirt","mcl_core:gravel"}) local nn = minetest.find_nodes_in_area(p1,p2,{"group:material_stone","group:dirt","mcl_core:gravel"})
@ -37,9 +37,9 @@ local function makegeode(pos,def,pr)
set_node_no_bedrock(nn[i],{name="mcl_amethyst:amethyst_block"}) set_node_no_bedrock(nn[i],{name="mcl_amethyst:amethyst_block"})
end end
for k,v in pairs(minetest.find_nodes_in_area(p1,p2,{"mcl_amethyst:amethyst_block"})) do for _, v in pairs(minetest.find_nodes_in_area(p1,p2,{"mcl_amethyst:amethyst_block"})) do
local all_amethyst = true local all_amethyst = true
for kk,vv in pairs(adjacents) do for _, vv in pairs(adjacents) do
local pp = vector.add(v,vv) local pp = vector.add(v,vv)
local an = minetest.get_node(pp) local an = minetest.get_node(pp)
if an.name ~= "mcl_amethyst:amethyst_block" then if an.name ~= "mcl_amethyst:amethyst_block" then
@ -58,13 +58,13 @@ local function makegeode(pos,def,pr)
if all_amethyst then set_node_no_bedrock(v,{name="air"}) end if all_amethyst then set_node_no_bedrock(v,{name="air"}) end
end end
for _,v in pairs(calcite) do for _, v in pairs(calcite) do
for _,vv in pairs(minetest.find_nodes_in_area(vector.offset(v,-1,-1,-1),vector.offset(v,1,1,1),{"group:material_stone"})) do for _, vv in pairs(minetest.find_nodes_in_area(vector.offset(v,-1,-1,-1),vector.offset(v,1,1,1),{"group:material_stone"})) do
set_node_no_bedrock(vv,{name="mcl_blackstone:basalt_smooth"}) set_node_no_bedrock(vv,{name="mcl_blackstone:basalt_smooth"})
end end
end end
for k,v in pairs(minetest.find_nodes_in_area_under_air(p1,p2,{"mcl_amethyst:amethyst_block","mcl_amethyst:budding_amethyst_block"})) do for _, v in pairs(minetest.find_nodes_in_area_under_air(p1,p2,{"mcl_amethyst:amethyst_block","mcl_amethyst:budding_amethyst_block"})) do
local r = pr:next(1,50) local r = pr:next(1,50)
if r < 10 then if r < 10 then
set_node_no_bedrock(vector.offset(v,0,1,0),{name="mcl_amethyst:amethyst_cluster",param2=1}) set_node_no_bedrock(vector.offset(v,0,1,0),{name="mcl_amethyst:amethyst_cluster",param2=1})

View file

@ -13,9 +13,11 @@ local function spawn_mobs(p1,p2,vi,zv)
elseif zv and vi then elseif zv and vi then
return return
end end
vi = minetest.add_entity(vector.offset(mc[1],0,1,0),"mobs_mc:villager") vi = minetest.add_entity(vector.offset(vp,0,1,0),"mobs_mc:villager")
zv = minetest.add_entity(vector.offset(mc[2],0,1,0),"mobs_mc:villager_zombie") zv = minetest.add_entity(vector.offset(zp,0,1,0),"mobs_mc:villager_zombie")
minetest.after(1,spawn_mobs,p1,p2,vi,zv) if vi and vi:get_pos() and zv and zv:get_pos() then
minetest.after(1,spawn_mobs,p1,p2,vi,zv)
end
end end
end end
@ -78,7 +80,7 @@ local function igloo_callback(cpos,def,pr,p1,p2,size,rotation)
vl_structures.place_schematic(bpos, -1, path, rotation, { vl_structures.place_schematic(bpos, -1, path, rotation, {
force_place = true, force_place = true,
prepare = { tolerance = -1, foundation = false, clear = false }, prepare = { tolerance = -1, foundation = false, clear = false },
after_place = function(p1, p2) after_place = function(_, _, pr, p1, p2)
-- Generate ladder to basement -- Generate ladder to basement
local ladder = {name="mcl_core:ladder", param2=minetest.dir_to_wallmounted(tdir)} local ladder = {name="mcl_core:ladder", param2=minetest.dir_to_wallmounted(tdir)}
-- TODO: use voxelmanip? -- TODO: use voxelmanip?

View file

@ -22,7 +22,7 @@ vl_structures.register_structure("jungle_temple",{
{ itemstring = "mcl_mobitems:bone", weight = 20, amount_min = 4, amount_max=6 }, { itemstring = "mcl_mobitems:bone", weight = 20, amount_min = 4, amount_max=6 },
{ itemstring = "mcl_mobitems:rotten_flesh", weight = 16, amount_min = 3, amount_max=7 }, { itemstring = "mcl_mobitems:rotten_flesh", weight = 16, amount_min = 3, amount_max=7 },
{ itemstring = "mcl_core:gold_ingot", weight = 15, amount_min = 2, amount_max = 7 }, { itemstring = "mcl_core:gold_ingot", weight = 15, amount_min = 2, amount_max = 7 },
--{ itemstring = "mcl_bamboo:bamboo", weight = 15, amount_min = 1, amount_max=3 }, --FIXME BAMBOO { itemstring = "mcl_bamboo:bamboo", weight = 15, amount_min = 1, amount_max=3 },
{ itemstring = "mcl_core:iron_ingot", weight = 15, amount_min = 1, amount_max = 5 }, { itemstring = "mcl_core:iron_ingot", weight = 15, amount_min = 1, amount_max = 5 },
{ itemstring = "mcl_core:diamond", weight = 3, amount_min = 1, amount_max = 3 }, { itemstring = "mcl_core:diamond", weight = 3, amount_min = 1, amount_max = 3 },
{ itemstring = "mcl_mobitems:saddle", weight = 3, }, { itemstring = "mcl_mobitems:saddle", weight = 3, },

View file

@ -1,5 +1,4 @@
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname)
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
local cold_oceans = { local cold_oceans = {

View file

@ -1,6 +1,5 @@
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
--local S = minetest.get_translator(modname)
local water_level = minetest.get_mapgen_setting("water_level") local water_level = minetest.get_mapgen_setting("water_level")
local spawnon = { "mcl_stairs:slab_prismarine_dark" } local spawnon = { "mcl_stairs:slab_prismarine_dark" }
@ -81,7 +80,9 @@ vl_structures.register_structure("ocean_temple",{
persist = 0.001, persist = 0.001,
flags = "absvalue", flags = "absvalue",
}, },
flags = "force_placement",
force_place = true, force_place = true,
prepare = { tolerance = -1, clear = false, foundation = false },
biomes = ocean_biomes, biomes = ocean_biomes,
y_max = water_level-4, y_max = water_level-4,
y_min = mcl_vars.mg_overworld_min, y_min = mcl_vars.mg_overworld_min,
@ -89,9 +90,8 @@ vl_structures.register_structure("ocean_temple",{
modpath .. "/schematics/mcl_structures_ocean_temple.mts", modpath .. "/schematics/mcl_structures_ocean_temple.mts",
modpath .. "/schematics/mcl_structures_ocean_temple_2.mts", modpath .. "/schematics/mcl_structures_ocean_temple_2.mts",
}, },
prepare = { tolerance = -1, clear = false, foundation = false },
y_offset = function(pr) return pr:next(-2,0) end, y_offset = function(pr) return pr:next(-2,0) end,
after_place = function(p,def,pr,p1,p2) after_place = function(p, _, pr, p1, p2)
vl_structures.spawn_mobs("mobs_mc:guardian",spawnon,p1,p2,pr,5,true) vl_structures.spawn_mobs("mobs_mc:guardian",spawnon,p1,p2,pr,5,true)
vl_structures.spawn_mobs("mobs_mc:guardian_elder",spawnon,p1,p2,pr,1,true) vl_structures.spawn_mobs("mobs_mc:guardian_elder",spawnon,p1,p2,pr,1,true)
vl_structures.construct_nodes(p1,p2,{"group:wall"}) vl_structures.construct_nodes(p1,p2,{"group:wall"})

View file

@ -57,7 +57,7 @@ vl_structures.register_structure("pillager_outpost",{
} }
}} }}
}, },
after_place = function(p,def,pr) after_place = function(p,_,pr) -- fixme: use p1, p2 from the callback?
local p1, p2 = vector.offset(p,-9,0,-9), vector.offset(p,9,32,9) local p1, p2 = vector.offset(p,-9,0,-9), vector.offset(p,9,32,9)
vl_structures.spawn_mobs("mobs_mc:pillager",spawnon,p1,p2,pr,5) vl_structures.spawn_mobs("mobs_mc:pillager",spawnon,p1,p2,pr,5)
vl_structures.spawn_mobs("mobs_mc:parrot",{"mesecons_pressureplates:pressure_plate_stone_off"},p1,p2,pr,3) vl_structures.spawn_mobs("mobs_mc:parrot",{"mesecons_pressureplates:pressure_plate_stone_off"},p1,p2,pr,3)

View file

@ -4,7 +4,7 @@ local modpath = minetest.get_modpath(modname)
local function get_replacements(b,c,pr) local function get_replacements(b,c,pr)
local r = {} local r = {}
if not b then return r end if not b then return r end
for k,v in pairs(b) do for _, v in pairs(b) do
if pr:next(1,100) < c then table.insert(r,v) end if pr:next(1,100) < c then table.insert(r,v) end
end end
return r return r

View file

@ -1,6 +1,5 @@
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
--local S = minetest.get_translator(modname)
local water_level = minetest.get_mapgen_setting("water_level") local water_level = minetest.get_mapgen_setting("water_level")
--schematics by chmodsayshello --schematics by chmodsayshello
@ -91,6 +90,8 @@ local beach_biomes = {
"Jungle_shore" "Jungle_shore"
} }
-- FIXME: integrate treasure maps from MCLA
vl_structures.register_structure("shipwreck",{ vl_structures.register_structure("shipwreck",{
place_on = {"group:sand","mcl_core:gravel"}, place_on = {"group:sand","mcl_core:gravel"},
spawn_by = {"group:water"}, spawn_by = {"group:water"},
@ -127,13 +128,13 @@ vl_structures.register_structure("shipwreck",{
{ itemstring = "mcl_core:coal_lump", weight = 6, amount_min = 2, amount_max = 8 }, { itemstring = "mcl_core:coal_lump", weight = 6, amount_min = 2, amount_max = 8 },
{ itemstring = "mcl_mobitems:rotten_flesh", weight = 5, amount_min = 5, amount_max = 24 }, { itemstring = "mcl_mobitems:rotten_flesh", weight = 5, amount_min = 5, amount_max = 24 },
{ itemstring = "mcl_farming:potato_item", weight = 3, amount_min = 1, amount_max = 5 }, { itemstring = "mcl_farming:potato_item", weight = 3, amount_min = 1, amount_max = 5 },
{ itemstring = "mcl_armor:helmet_leather_enchanted", weight = 3, func = function(stack, pr) { itemstring = "mcl_armor:helmet_leather_enchanted", weight = 3, func = function(stack, _)
mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}) end }, mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}) end },
{ itemstring = "mcl_armor:chestplate_leather_enchanted", weight = 3, func = function(stack, pr) { itemstring = "mcl_armor:chestplate_leather_enchanted", weight = 3, func = function(stack, _)
mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}) end }, mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}) end },
{ itemstring = "mcl_armor:leggings_leather_enchanted", weight = 3, func = function(stack, pr) { itemstring = "mcl_armor:leggings_leather_enchanted", weight = 3, func = function(stack, _)
mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}) end }, mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}) end },
{ itemstring = "mcl_armor:boots_leather_enchanted", weight = 3, func = function(stack, pr) { itemstring = "mcl_armor:boots_leather_enchanted", weight = 3, func = function(stack, _)
mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}) end }, mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}) end },
{ itemstring = "mcl_bamboo:bamboo", weight = 2, amount_min = 1, amount_max = 3 }, { itemstring = "mcl_bamboo:bamboo", weight = 2, amount_min = 1, amount_max = 3 },
{ itemstring = "mcl_farming:pumpkin", weight = 2, amount_min = 1, amount_max = 3 }, { itemstring = "mcl_farming:pumpkin", weight = 2, amount_min = 1, amount_max = 3 },

View file

@ -14,11 +14,14 @@ local function spawn_witch(p1,p2)
witch._home = c witch._home = c
witch.can_despawn = false witch.can_despawn = false
end end
local cat = minetest.add_entity(vector.offset(nn[math.random(#nn)],0,1,0),"mobs_mc:cat"):get_luaentity() local catobject = minetest.add_entity(vector.offset(nn[math.random(#nn)],0,1,0),"mobs_mc:cat")
cat.object:set_properties({textures = {"mobs_mc_cat_black.png"}}) if catobject and catobject:get_pos() then
cat.owner = "!witch!" --so it's not claimable by player local cat=catobject:get_luaentity()
cat._home = c cat.object:set_properties({textures = {"mobs_mc_cat_black.png"}})
cat.can_despawn = false cat.owner = "!witch!" --so it's not claimable by player
cat._home = c
cat.can_despawn = false
end
return return
end end
end end

View file

@ -1,7 +1,5 @@
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname)
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
local peaceful = minetest.settings:get_bool("only_peaceful_mobs", false)
local spawnon = {"mcl_deepslate:deepslate","mcl_core:birchwood","mcl_wool:red_carpet","mcl_wool:brown_carpet"} local spawnon = {"mcl_deepslate:deepslate","mcl_core:birchwood","mcl_wool:red_carpet","mcl_wool:brown_carpet"}

View file

@ -10,19 +10,6 @@ local adjacents = {
vector.new(0,-1,0) vector.new(0,-1,0)
} }
local plane_adjacents = {
vector.new(1,0,0),
vector.new(-1,0,0),
vector.new(0,0,1),
vector.new(0,0,-1),
}
local function set_node_no_bedrock(pos,node)
local n = minetest.get_node(pos)
if n.name == "mcl_core:bedrock" then return end
return minetest.set_node(pos,node)
end
local function airtower(pos,tbl,h) local function airtower(pos,tbl,h)
for i=1,h do for i=1,h do
table.insert(tbl,vector.offset(pos,0,i,0)) table.insert(tbl,vector.offset(pos,0,i,0))
@ -32,7 +19,7 @@ end
local function makelake(pos,size,liquid,placein,border,pr,noair) local function makelake(pos,size,liquid,placein,border,pr,noair)
local p1, p2 = vector.offset(pos,-size,-1,-size), vector.offset(pos,size,-1,size) local p1, p2 = vector.offset(pos,-size,-1,-size), vector.offset(pos,size,-1,size)
local e1, e2 = vector.offset(pos,-size,-2,-size), vector.offset(pos,size,15,size) local e1, e2 = vector.offset(pos,-size,-2,-size), vector.offset(pos,size,15,size)
minetest.emerge_area(e1, e2, function(blockpos, action, calls_remaining, param) minetest.emerge_area(e1, e2, function(_, _, calls_remaining)
if calls_remaining ~= 0 then return end if calls_remaining ~= 0 then return end
local nn = minetest.find_nodes_in_area(p1,p2,placein) local nn = minetest.find_nodes_in_area(p1,p2,placein)
if not nn[1] then return end if not nn[1] then return end
@ -165,7 +152,6 @@ vl_structures.register_structure("fallen_tree",{
persist = 0.66 persist = 0.66
}, },
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
sidelen = 10,
solid_ground = true, solid_ground = true,
y_max = mcl_vars.mg_overworld_max, y_max = mcl_vars.mg_overworld_max,
y_min = minetest.get_mapgen_setting("water_level"), y_min = minetest.get_mapgen_setting("water_level"),
@ -207,7 +193,7 @@ vl_structures.register_structure("water_lake",{
flags = "place_center_x, place_center_z, all_floors", flags = "place_center_x, place_center_z, all_floors",
y_max = mcl_vars.mg_overworld_max, y_max = mcl_vars.mg_overworld_max,
y_min = minetest.get_mapgen_setting("water_level"), y_min = minetest.get_mapgen_setting("water_level"),
place_func = function(pos,def,pr) place_func = function(pos,_,pr)
return makelake(pos,5,"mcl_core:water_source",{"group:material_stone", "group:sand", "group:dirt","group:grass_block"},"mcl_core:dirt_with_grass",pr) return makelake(pos,5,"mcl_core:water_source",{"group:material_stone", "group:sand", "group:dirt","group:grass_block"},"mcl_core:dirt_with_grass",pr)
end end
}) })
@ -228,7 +214,7 @@ vl_structures.register_structure("water_lake_mangrove_swamp",{
flags = "place_center_x, place_center_z, all_floors", flags = "place_center_x, place_center_z, all_floors",
y_max = mcl_vars.mg_overworld_max, y_max = mcl_vars.mg_overworld_max,
y_min = minetest.get_mapgen_setting("water_level"), y_min = minetest.get_mapgen_setting("water_level"),
place_func = function(pos,def,pr) place_func = function(pos, _, pr)
return makelake(pos,3,"mcl_core:water_source",{"group:material_stone", "group:sand", "group:dirt","group:grass_block","mcl_mud:mud"},"mcl_mud:mud",pr,true) return makelake(pos,3,"mcl_core:water_source",{"group:material_stone", "group:sand", "group:dirt","group:grass_block","mcl_mud:mud"},"mcl_mud:mud",pr,true)
end end
}) })
@ -251,7 +237,7 @@ vl_structures.register_structure("basalt_column",{
y_max = mcl_vars.mg_nether_max - 20, y_max = mcl_vars.mg_nether_max - 20,
y_min = mcl_vars.mg_lava_nether_max + 1, y_min = mcl_vars.mg_lava_nether_max + 1,
biomes = { "BasaltDelta" }, biomes = { "BasaltDelta" },
place_func = function(pos,def,pr) place_func = function(pos, _, pr)
local nn = minetest.find_nodes_in_area(vector.offset(pos,-5,-1,-5),vector.offset(pos,5,-1,5),{"air","mcl_blackstone:basalt","mcl_blackstone:blackstone"}) local nn = minetest.find_nodes_in_area(vector.offset(pos,-5,-1,-5),vector.offset(pos,5,-1,5),{"air","mcl_blackstone:basalt","mcl_blackstone:blackstone"})
table.sort(nn,function(a, b) table.sort(nn,function(a, b)
return vector.distance(vector.new(pos.x,0,pos.z), a) < vector.distance(vector.new(pos.x,0,pos.z), b) return vector.distance(vector.new(pos.x,0,pos.z), a) < vector.distance(vector.new(pos.x,0,pos.z), b)
@ -293,7 +279,7 @@ vl_structures.register_structure("basalt_pillar",{
y_max = mcl_vars.mg_nether_max-40, y_max = mcl_vars.mg_nether_max-40,
y_min = mcl_vars.mg_lava_nether_max + 1, y_min = mcl_vars.mg_lava_nether_max + 1,
biomes = { "BasaltDelta" }, biomes = { "BasaltDelta" },
place_func = function(pos,def,pr) place_func = function(pos, _, pr)
local nn = minetest.find_nodes_in_area(vector.offset(pos,-2,-1,-2),vector.offset(pos,2,-1,2),{"air","mcl_blackstone:basalt","mcl_blackstone:blackstone"}) local nn = minetest.find_nodes_in_area(vector.offset(pos,-2,-1,-2),vector.offset(pos,2,-1,2),{"air","mcl_blackstone:basalt","mcl_blackstone:blackstone"})
table.sort(nn,function(a, b) table.sort(nn,function(a, b)
return vector.distance(vector.new(pos.x,0,pos.z), a) < vector.distance(vector.new(pos.x,0,pos.z), b) return vector.distance(vector.new(pos.x,0,pos.z), a) < vector.distance(vector.new(pos.x,0,pos.z), b)
@ -337,7 +323,7 @@ vl_structures.register_structure("lavadelta",{
y_max = mcl_vars.mg_nether_max, y_max = mcl_vars.mg_nether_max,
y_min = mcl_vars.mg_lava_nether_max + 1, y_min = mcl_vars.mg_lava_nether_max + 1,
biomes = { "BasaltDelta" }, biomes = { "BasaltDelta" },
place_func = function(pos,def,pr) place_func = function(pos, _, pr)
local nn = minetest.find_nodes_in_area_under_air(vector.offset(pos,-10,-1,-10),vector.offset(pos,10,-2,10),{"mcl_blackstone:basalt","mcl_blackstone:blackstone","mcl_nether:netherrack"}) local nn = minetest.find_nodes_in_area_under_air(vector.offset(pos,-10,-1,-10),vector.offset(pos,10,-2,10),{"mcl_blackstone:basalt","mcl_blackstone:blackstone","mcl_nether:netherrack"})
table.sort(nn,function(a, b) table.sort(nn,function(a, b)
return vector.distance(vector.new(pos.x,0,pos.z), a) < vector.distance(vector.new(pos.x,0,pos.z), b) return vector.distance(vector.new(pos.x,0,pos.z), a) < vector.distance(vector.new(pos.x,0,pos.z), b)

View file

@ -241,7 +241,7 @@ function mcl_villages.place_schematics(vm, settlement, blockseed, pr)
minp, minp,
schematic, schematic,
rotation, rotation,
nil, { ["mcl_core:dirt_with_grass"]=schematic.surface_mat or "mcl_core:dirt" },
true, true,
{ place_center_x = false, place_center_y = false, place_center_z = false } { place_center_x = false, place_center_y = false, place_center_z = false }
) )
@ -279,6 +279,10 @@ function mcl_villages.place_schematics(vm, settlement, blockseed, pr)
local biome_name = minetest.get_biome_name(biome_data.biome) local biome_name = minetest.get_biome_name(biome_data.biome)
mcl_villages.paths(blockseed, biome_name) mcl_villages.paths(blockseed, biome_name)
for i, building in ipairs(settlement) do
init_nodes(building.minp, building.maxp, pr)
end
-- this will run delayed actions, such as spawning mobs -- this will run delayed actions, such as spawning mobs
minetest.set_node(bell_center_pos, { name = "mcl_villages:village_block" }) minetest.set_node(bell_center_pos, { name = "mcl_villages:village_block" })
local meta = minetest.get_meta(bell_center_pos) local meta = minetest.get_meta(bell_center_pos)
@ -287,13 +291,9 @@ function mcl_villages.place_schematics(vm, settlement, blockseed, pr)
meta:set_string("infotext", S("The timer for this @1 has not run yet!", bell_center_node_type)) meta:set_string("infotext", S("The timer for this @1 has not run yet!", bell_center_node_type))
minetest.get_node_timer(bell_center_pos):start(1.0) minetest.get_node_timer(bell_center_pos):start(1.0)
for i, building in ipairs(settlement) do -- read back any changes (fixme: would be better if we would not need this often.
init_nodes(vector.offset(building.minp,-2,-2,-2), vector.offset(building.maxp,2,2,2), pr) --local emin, emax = vm:get_emerged_area()
end --vm:read_from_map(emin, emax)
-- read back any changes
local emin, emax = vm:get_emerged_area()
vm:read_from_map(emin, emax)
end end
function mcl_villages.post_process_village(blockseed) function mcl_villages.post_process_village(blockseed)

View file

@ -22,12 +22,12 @@ minetest.register_node("mcl_villages:structblock", {drawtype="airlike",groups =
local function build_a_settlement(minp, maxp, blockseed) local function build_a_settlement(minp, maxp, blockseed)
if mcl_villages.village_exists(blockseed) then return end if mcl_villages.village_exists(blockseed) then return end
local pr = PcgRandom(blockseed) local pr = PcgRandom(blockseed)
local lvm = VoxelManip(minp, maxp) local vm = VoxelManip(minp, maxp)
local settlement = mcl_villages.create_site_plan(lvm, minp, maxp, pr) local settlement = mcl_villages.create_site_plan(vm, minp, maxp, pr)
if not settlement then return false, false end if not settlement then return false, false end
-- all foundations first, then all buildings, to avoid damaging very close buildings -- all foundations first, then all buildings, to avoid damaging very close buildings
mcl_villages.terraform(lvm, settlement, pr) mcl_villages.terraform(vm, settlement, pr)
mcl_villages.place_schematics(lvm, settlement, blockseed, pr) mcl_villages.place_schematics(vm, settlement, blockseed, pr)
mcl_villages.add_village(blockseed, settlement) mcl_villages.add_village(blockseed, settlement)
--lvm:write_to_map(true) -- destory paths as of now --lvm:write_to_map(true) -- destory paths as of now
--mcl_villages.paths(blockseed) -- TODO: biome --mcl_villages.paths(blockseed) -- TODO: biome
@ -110,7 +110,7 @@ minetest.register_node("mcl_villages:village_block", {
-- Somethings don't work reliably when done in the map building -- Somethings don't work reliably when done in the map building
-- so we use a timer to run them later when they work more reliably -- so we use a timer to run them later when they work more reliably
-- e.g. spawning mobs, running minetest.find_path -- e.g. spawning mobs, running minetest.find_path
on_timer = function(pos, elapsed) on_timer = function(pos, _)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local blockseed = meta:get_string("blockseed") local blockseed = meta:get_string("blockseed")
local node_type = meta:get_string("node_type") local node_type = meta:get_string("node_type")
@ -283,14 +283,26 @@ mcl_villages.register_building({
}) })
mcl_villages.register_building({ mcl_villages.register_building({
name = "fletcher", name = "fletcher_tiny",
group = "g:fletcher",
mts = schem_path .. "bogner.mts", mts = schem_path .. "bogner.mts",
num_others = 8, num_others = 8,
max_jobs = 6,
yadjust = 0, yadjust = 0,
}) })
mcl_villages.register_building({
name = "fletcher",
group = "g:fletcher",
mts = schem_path .. "new_villages/fletcher.mts",
num_others = 8,
min_jobs = 7,
yadjust = 1,
})
mcl_villages.register_building({ mcl_villages.register_building({
name = "library", name = "library",
group = "g:library",
mts = schem_path .. "new_villages/library.mts", mts = schem_path .. "new_villages/library.mts",
min_jobs = 12, min_jobs = 12,
max_jobs = 99, max_jobs = 99,
@ -300,6 +312,7 @@ mcl_villages.register_building({
mcl_villages.register_building({ mcl_villages.register_building({
name = "librarian", name = "librarian",
group = "g:library",
mts = schem_path .. "schreiber.mts", mts = schem_path .. "schreiber.mts",
min_jobs = 1, min_jobs = 1,
max_jobs = 11, max_jobs = 11,
@ -350,6 +363,7 @@ mcl_villages.register_building({
mcl_villages.register_building({ mcl_villages.register_building({
name = "chapel", name = "chapel",
group = "g:church",
mts = schem_path .. "new_villages/chapel.mts", mts = schem_path .. "new_villages/chapel.mts",
num_others = 8, num_others = 8,
min_jobs = 1, min_jobs = 1,
@ -358,14 +372,25 @@ mcl_villages.register_building({
}) })
mcl_villages.register_building({ mcl_villages.register_building({
name = "church", name = "church_european",
group = "g:church",
mts = schem_path .. "kirche.mts", mts = schem_path .. "kirche.mts",
num_others = 20, num_others = 20,
min_jobs = 10, min_jobs = 8,
max_jobs = 99, max_jobs = 99,
yadjust = 0, yadjust = 0,
}) })
mcl_villages.register_building({
name = "church",
group = "g:church",
mts = schem_path .. "new_villages/church.mts",
num_others = 20,
min_jobs = 8,
max_jobs = 99,
yadjust = 1,
})
mcl_villages.register_building({ mcl_villages.register_building({
name = "farm_small", name = "farm_small",
mts = schem_path .. "new_villages/farm_small_1.mts", mts = schem_path .. "new_villages/farm_small_1.mts",

View file

@ -128,8 +128,8 @@ function vl_structures.place_structure(pos, def, pr, blockseed, rot)
end end
end end
local EMPTY_SCHEMATIC = { size = {x = 1, y = 1, z = 1}, data = { { name = "ignore" } } } -- local EMPTY_SCHEMATIC = { size = {x = 1, y = 1, z = 1}, data = { { name = "ignore" } } }
-- local EMPTY_SCHEMATIC = { size = {x = 0, y = 0, z = 0}, data = { } } local EMPTY_SCHEMATIC = { size = {x = 0, y = 0, z = 0}, data = { } }
--- Register a structure --- Register a structure
-- @param name string: Structure name -- @param name string: Structure name
@ -142,6 +142,7 @@ function vl_structures.register_structure(name,def)
if not def.noise_params and def.chunk_probability and not def.fill_ratio then if not def.noise_params and def.chunk_probability and not def.fill_ratio then
def.fill_ratio = 1.1/80/80 -- 1 per chunk, controlled by chunk probability only def.fill_ratio = 1.1/80/80 -- 1 per chunk, controlled by chunk probability only
end end
def.flags = def.flags or vl_structures.DEFAULT_FLAGS
if def.filenames then if def.filenames then
for _, filename in ipairs(def.filenames) do for _, filename in ipairs(def.filenames) do
if not mcl_util.file_exists(filename) then if not mcl_util.file_exists(filename) then
@ -153,7 +154,7 @@ function vl_structures.register_structure(name,def)
if def.place_on then if def.place_on then
minetest.register_on_mods_loaded(function() minetest.register_on_mods_loaded(function()
def.deco = mcl_mapgen_core.register_decoration({ def.deco = mcl_mapgen_core.register_decoration({
name = "vl_structures:deco_"..name, name = "vl_structures:"..name,
priority = def.priority or (def.terrain_feature and 900) or 100, -- run before regular decorations priority = def.priority or (def.terrain_feature and 900) or 100, -- run before regular decorations
deco_type = "schematic", deco_type = "schematic",
schematic = EMPTY_SCHEMATIC, -- use gennotify only schematic = EMPTY_SCHEMATIC, -- use gennotify only
@ -166,29 +167,26 @@ function vl_structures.register_structure(name,def)
flags = def.flags, flags = def.flags,
biomes = def.biomes, biomes = def.biomes,
y_max = def.y_max, y_max = def.y_max,
y_min = def.y_min y_min = def.y_min,
}, function() -- callback when mcl_mapgen_core has reordered the decoration calls gen_callback = function(t,minp,maxp,blockseed)
def.deco_id = minetest.get_decoration_id("vl_structures:deco_"..name) for _, pos in ipairs(t) do
minetest.set_gen_notify({decoration=true}, { def.deco_id }) local pr = PcgRandom(minetest.hash_node_position(pos) + worldseed + RANDOM_SEED_OFFSET)
end) if def.chunk_probability == nil or pr:next(0, 1e9) * 1e-9 * def.chunk_probability <= structure_boost then
vl_structures.place_structure(vector_offset(pos, 0, 1, 0), def, pr, blockseed)
if def.chunk_probability ~= nil then break end -- allow only one per gennotify, e.g., on multiple surfaces
end
end
end
})
end) end)
end end
end end
-- To avoid a cyclic dependency, run this when modules have finished loading -- To avoid a cyclic dependency, run this when modules have finished loading
minetest.register_on_mods_loaded(function() minetest.register_on_mods_loaded(function()
mcl_mapgen_core.register_generator("structures", nil, function(minp, maxp, blockseed) mcl_mapgen_core.register_generator("static structures", nil, function(minp, maxp, blockseed)
local gennotify = minetest.get_mapgen_object("gennotify")
for _,struct in pairs(vl_structures.registered_structures) do for _,struct in pairs(vl_structures.registered_structures) do
if struct.deco_id then if struct.static_pos then
for _, pos in pairs(gennotify["decoration#"..struct.deco_id] or {}) do
local pr = PcgRandom(minetest.hash_node_position(pos) + worldseed + RANDOM_SEED_OFFSET)
if struct.chunk_probability == nil or pr:next(0, 1e9) * 1e-9 * struct.chunk_probability <= structure_boost then
vl_structures.place_structure(vector_offset(pos, 0, 1, 0), struct, pr, blockseed)
if struct.chunk_probability ~= nil then break end -- allow only one per gennotify, e.g., on multiple surfaces
end
end
elseif struct.static_pos then
local pr -- initialize only when needed below local pr -- initialize only when needed below
for _, pos in pairs(struct.static_pos) do for _, pos in pairs(struct.static_pos) do
if vector.in_area(pos, minp, maxp) then if vector.in_area(pos, minp, maxp) then

View file

@ -4,7 +4,7 @@ local modpath = minetest.get_modpath(modname)
--- /spawnstruct chat command --- /spawnstruct chat command
minetest.register_chatcommand("spawnstruct", { minetest.register_chatcommand("spawnstruct", {
params = mcl_dungeons and "dungeon" or "", params = "",
description = S("Generate a pre-defined structure near your position."), description = S("Generate a pre-defined structure near your position."),
privs = {debug = true}, privs = {debug = true},
func = function(name, param) func = function(name, param)
@ -35,7 +35,7 @@ minetest.register_chatcommand("spawnstruct", {
end end
}) })
minetest.register_on_mods_loaded(function() minetest.register_on_mods_loaded(function()
local p = minetest.registered_chatcommands["spawnstruct"].params local p = _G["mcl_dungeons"] and "dungeon" or ""
for n,_ in pairs(vl_structures.registered_structures) do for n,_ in pairs(vl_structures.registered_structures) do
p = (p ~= "" and (p.." | ") or "")..n p = (p ~= "" and (p.." | ") or "")..n
end end