Register mcl2 overworld ores for multi_map layers #3

Merged
cora merged 1 commits from biomegen into master 2022-05-22 01:38:33 +02:00
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
multi_map.number_of_layers = 24 -- How may layers to generate
multi_map.layers_start_chunk = 0 -- Y level where to start generating layers, in chunks
multi_map.layer_height_chunks = 32 -- Height of each layer, in chunks
multi_map.wrap_layers = false
multi_map.number_of_layers = 12 -- How may layers to generate
multi_map.layers_start_chunk = 500 -- Y level where to start generating layers, in chunks
multi_map.layer_height_chunks = 20 -- Height of each layer, in chunks
multi_map.wrap_layers = true
-- Either MT engine defaults or derived from above values, to be used for more readable calculations
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()
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
-- y = absolute y value to be translated to layer
function multi_map.set_current_layer(y)
@ -396,7 +399,7 @@ minetest.register_on_generated(function(minp, maxp,seed)
else
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)
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)
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.map_cache = {}
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_generator(0, mmgen_testauri.generate )
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(2, mmgen_simple.generate, {nodetype="mcl_core:stone"})
multi_map.register_generator(0, mmgen_testauri.generate,{biomegen=true})
multi_map.register_generator(1, mmgen_mytest.generate, {biomegen=true})
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(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(1, { name = "testmg"})

View File

@ -1,42 +1,33 @@
mmgen_mytest = {}
function mmgen_mytest.generate(current_layer, vm, a, data, minp, maxp, offset_minp, offset_maxp,arg,seed)
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_grass = minetest.get_content_id("mcl_core:dirt_with_grass")
local c_water = minetest.get_content_id("mcl_core:water_source")
local c_air = minetest.get_content_id("air")
local t1 = os.clock()
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 nvals=multi_map.get_global_3dmap_flat("terrain", {x=sidelen, y=sidelen, z=sidelen}, {x=minp.x, y=minp.y, z=minp.z})
local ni = 1
for z = minp.z, maxp.z do
for y = minp.y, maxp.y do
for x = minp.x, maxp.x do
local c_stone = minetest.get_content_id("mcl_core:stone")
local c_water = minetest.get_content_id("mcl_core:water_source")
local sidelen = maxp.x - minp.x + 1
local nvals=multi_map.get_global_3dmap_flat("terrain", {x=sidelen, y=sidelen, z=sidelen}, {x=minp.x, y=minp.y, z=minp.z})
local ni = 1
for z = minp.z, maxp.z do
for y = minp.y, maxp.y do
for x = minp.x, maxp.x do
local yy=multi_map.get_offset_y(y)
if nvals[ni] - (yy - 25) / 55 > 0.5 then
local vi = a:index(x, y, z)
if yy < 1 then
data[vi] = c_stone
else
data[vi] = c_stone
end
elseif yy < 1 then
local vi = a:index(x, y, z)
data[vi] = c_water
end
ni = ni + 1
end
end
end
if nvals[ni] - (yy - 25) / 55 > 0.5 then
local vi = a:index(x, y, z)
if yy < 1 then
data[vi] = c_stone
else
data[vi] = c_stone
end
elseif yy < 1 then
local vi = a:index(x, y, z)
data[vi] = c_water
end
ni = ni + 1
end
end
end
end