Merge pull request 'Register mcl2 overworld ores for multi_map layers' (#3) from biomegen into master

Reviewed-on: MineClone2/mcl_multi_map#3
This commit is contained in:
cora 2022-05-21 23:38:33 +00:00
commit f71182efea
3 changed files with 60 additions and 45 deletions

View File

@ -1,8 +1,8 @@
-- External settings that can be set by mods using multi_map -- External settings that can be set by mods using multi_map
multi_map.number_of_layers = 24 -- How may layers to generate multi_map.number_of_layers = 12 -- How may layers to generate
multi_map.layers_start_chunk = 0 -- Y level where to start generating layers, in chunks multi_map.layers_start_chunk = 500 -- Y level where to start generating layers, in chunks
multi_map.layer_height_chunks = 32 -- Height of each layer, in chunks multi_map.layer_height_chunks = 20 -- Height of each layer, in chunks
multi_map.wrap_layers = false multi_map.wrap_layers = true
-- Either MT engine defaults or derived from above values, to be used for more readable calculations -- Either MT engine defaults or derived from above values, to be used for more readable calculations
multi_map.layer_height = nil multi_map.layer_height = nil
@ -35,6 +35,9 @@ local use_biomegen = biomegen and minetest.settings:get_bool("multi_map_use_biom
local vm_data = {} -- reuse the massive VoxelManip memory buffer instead of creating on every on_generate() local vm_data = {} -- reuse the massive VoxelManip memory buffer instead of creating on every on_generate()
multi_map.layer_height = multi_map.layer_height_chunks * 80
multi_map.layers_start = multi_map.layers_start_chunk * 80
multi_map.half_layer_height = multi_map.layer_height / 2
-- Set the current layer which the mapgen is generating -- Set the current layer which the mapgen is generating
-- y = absolute y value to be translated to layer -- y = absolute y value to be translated to layer
function multi_map.set_current_layer(y) function multi_map.set_current_layer(y)
@ -396,7 +399,7 @@ minetest.register_on_generated(function(minp, maxp,seed)
else else
for i,f in ipairs(t) do for i,f in ipairs(t) do
f.generator(multi_map.current_layer, vm, area, vm_data, minp, maxp, offset_minp, offset_maxp, f.arguments,seed) f.generator(multi_map.current_layer, vm, area, vm_data, minp, maxp, offset_minp, offset_maxp, f.arguments,seed)
if use_biomegen and ( not f.arguments or ( f.arguments and not f.arguments.nobiomoes ) ) then if use_biomegen and f.arguments and f.arguments.biomegen then
biomegen.generate_all(vm_data, area, vm, minp, maxp, seed) biomegen.generate_all(vm_data, area, vm, minp, maxp, seed)
end end
end end
@ -421,3 +424,22 @@ minetest.register_on_generated(function(minp, maxp,seed)
multi_map.last_used_layer = multi_map.current_layer multi_map.last_used_layer = multi_map.current_layer
multi_map.map_cache = {} multi_map.map_cache = {}
end) end)
minetest.register_on_mods_loaded(function()
if use_biomegen then
for _,o in pairs(minetest.registered_ores) do
for i=0,#multi_map.generators - 1 do
local l = multi_map.generators[i][1]
if l.arguments and l.arguments.biomegen and o.y_min > -1000 and o.y_max < 30000 then --only overworld ores
local o2 = table.copy(o)
o2.y_min = multi_map.get_absolute_centerpoint(i) + o.y_min
o2.y_max = multi_map.get_absolute_centerpoint(i) + o.y_max
minetest.register_ore(o2)
minetest.log(dump(multi_map.get_absolute_centerpoint(i)))
--minetest.log(dump(i))
end
end
end
end
end)

View File

@ -13,11 +13,13 @@ dofile(multi_map_generators_path.."/mmgen_mytest.lua")
multi_map.register_fallback_generator("Default Simple", mmgen_simple.generate) multi_map.register_fallback_generator("Default Simple", mmgen_simple.generate)
multi_map.register_generator(0, mmgen_testauri.generate ) multi_map.register_generator(0, mmgen_testauri.generate,{biomegen=true})
multi_map.register_generator(1, mmgen_mytest.generate, {stone="mcl_core:stone",dirt="mcl_core:dirt",grass="mcl_core:dirt_with_grass",water="mcl_core:water_source",air="air"}) multi_map.register_generator(1, mmgen_mytest.generate, {biomegen=true})
multi_map.register_generator(2, mmgen_simple.generate, {nodetype="mcl_core:stone"}) multi_map.register_generator(2, mmgen_simple.generate, {nodetype="mcl_core:stone",biomegen=true})
multi_map.register_generator(3, mmgen_simple.generate, {nodetype="mcl_core:obsidian"}) multi_map.register_generator(3, mmgen_simple.generate, {nodetype="mcl_core:obsidian"})
multi_map.register_generator(4, mmgen_levels.generate) multi_map.register_generator(4, mmgen_simple.generate, {nodetype="mcl_core:stone"})
multi_map.register_generator(5, mmgen_levels.generate)
multi_map.set_layer_params(0, { name = "testauri" }) multi_map.set_layer_params(0, { name = "testauri" })
multi_map.set_layer_params(1, { name = "testmg"}) multi_map.set_layer_params(1, { name = "testmg"})

View File

@ -3,17 +3,8 @@ mmgen_mytest = {}
function mmgen_mytest.generate(current_layer, vm, a, data, minp, maxp, offset_minp, offset_maxp,arg,seed) function mmgen_mytest.generate(current_layer, vm, a, data, minp, maxp, offset_minp, offset_maxp,arg,seed)
local t1 = os.clock() local t1 = os.clock()
local c_dirt = minetest.get_content_id("mcl_core:dirt")
local c_stone = minetest.get_content_id("mcl_core:stone") local c_stone = minetest.get_content_id("mcl_core:stone")
local c_grass = minetest.get_content_id("mcl_core:dirt_with_grass")
local c_water = minetest.get_content_id("mcl_core:water_source") local c_water = minetest.get_content_id("mcl_core:water_source")
local c_air = minetest.get_content_id("air")
if arg.stone then c_stone = minetest.get_content_id(arg.stone) end
if arg.dirt then c_dirt = minetest.get_content_id(arg.dirt) end
if arg.water then c_water = minetest.get_content_id(arg.water) end
if arg.grass then c_grass = minetest.get_content_id(arg.grass) end
if arg.air then c_air = minetest.get_content_id(arg.air) end
local sidelen = maxp.x - minp.x + 1 local sidelen = maxp.x - minp.x + 1