From 72e88f1980f80bd52d608c5f875042fd64ac2610 Mon Sep 17 00:00:00 2001 From: kay27 Date: Thu, 5 Aug 2021 04:01:07 +0400 Subject: [PATCH] Rename mapgen API methods, fix errors --- mods/CORE/mcl_mapgen/API.md | 157 +++++++++++++----------- mods/CORE/mcl_mapgen/init.lua | 138 ++++++++++----------- mods/MAPGEN/mcl_biomes/init.lua | 10 +- mods/MAPGEN/mcl_debrisgen/init.lua | 70 +++++------ mods/MAPGEN/mcl_debrisgen/mod.conf | 2 +- mods/MAPGEN/mcl_dungeons/init.lua | 42 ++++++- mods/MAPGEN/mcl_end_island/init.lua | 2 +- mods/MAPGEN/mcl_mapgen_core/init.lua | 88 ++++++------- mods/MAPGEN/mcl_ocean_monument/init.lua | 4 +- mods/MAPGEN/mcl_strongholds/init.lua | 4 +- mods/MAPGEN/mcl_villages/init.lua | 4 +- mods/MAPGEN/tsm_railcorridors/init.lua | 2 +- 12 files changed, 270 insertions(+), 253 deletions(-) diff --git a/mods/CORE/mcl_mapgen/API.md b/mods/CORE/mcl_mapgen/API.md index b5afbeb4d..20829e183 100644 --- a/mods/CORE/mcl_mapgen/API.md +++ b/mods/CORE/mcl_mapgen/API.md @@ -1,74 +1,83 @@ -# mcl_mapgen -============ -Helps to avoid problems caused by 'chunk-in-shell' feature of mapgen.cpp. -It also queues your generators to run them in proper order: - -## mcl_mapgen.register_chunk_generator(chunk_callback_function, priority) -========================================================================= -Registers callback function to be called when current chunk generation is finished. - `callback_function`: chunk callback function definition: - `function(minp, maxp, seed)`: - `minp` & `maxp`: minimum and maximum chunk position; - `seed`: seed of this mapchunk; - `priority` (optional): order number - the less, the earlier, - e.g. `mcl_mapgen.priorities.BUILDINGS` or `mcl_mapgen.priorities.LARGE_BUILDINGS` - -## mcl_mapgen.register_block_generator(callback_function, priority) -=================================================================== -Registers callback function to be called when block (usually 16x16x16 nodes) generation is finished. - `callback_function`: block callback function definition, see below; - `priority` (optional): order number - the less, the earlier, - e.g. `mcl_mapgen.priorities.BUILDINGS` or `mcl_mapgen.priorities.LARGE_BUILDINGS` - -## mcl_mapgen.register_block_generator_lvm(callback_function, priority) -======================================================================= -Registers callback function to be called when block (usually 16x16x16 nodes) generation is finished. -`vm_context` passes into callback function and should be returned back. - `callback_function`: block callback LVM function definition, see below; - `priority` (optional): order number - the less, the earlier, - e.g. `mcl_mapgen.priorities.BUILDINGS` or `mcl_mapgen.priorities.LARGE_BUILDINGS` - -## mcl_mapgen.register_chunk_generator_lvm(callback_function, priority) -======================================================================= -UNSAFE! See https://git.minetest.land/MineClone2/MineClone2/issues/1395 -Registers callback function to be called when current chunk generation is finished. -IT IS UNSAFE! GROUND CONTENT YOU PLACE (INCLUDING WATER AND AIR) CAN BE OVERWRITTEN BY cavegen. -ALL OTHER API FUNCTIONS ARE SAFE! USE THEM PLEASE! BUT WE NEED THIS FUNCTION STILL SOMETIMES, -WHEN WE NEED TO ACCESS MAPGEN OBJECTS like `heightmap`, `biomemap`, ETC. - `callback_function`: chunk callback LVM function definition, see below; - `function(vm_context)`: - Function MUST RETURN `vm_context` back anyway! It will passed into next callback function from the queue. - `vm_context`: a table which already contains some LVM data if the fields, and some of them can be added right in callback function: - `vm`: curent voxel manipulator object itself; - `blockseed`: seed of this mapchunk; - `minp` & `maxp`: minimum and maximum chunk position; - `emin` & `emax`: minimum and maximum chunk position WITH SHELL AROUND IT; - `area`: voxel area, can be helpful to access data; - `data`: LVM buffer data array, data loads into it before the callbacks; - `write`: set it to true in yout callback functionm, if you changed `data` and want to write it; - `data2`: LVM buffer data array of `param2`, !NO ANY DATA LOADS INTO IT BEFORE THE CALLBACKS! - you load it yourfels: - `vm_context.data2 = vm_context.data2 or vm_context.vm.get_param2_data(vm_context.lvm_param2_buffer)` - `write_param2`: set it to true in yout callback functionm, if you used `data2` and want to write it; - `lvm_param2_buffer`: static `param2` buffer pointer, used to load `data2` array; - `shadow`: set it to false to disable shadow propagation; - `heightmap`: mapgen object contanting y coordinates of ground level, - !NO ANY DATA LOADS INTO IT BEFORE THE CALLBACKS! - you load it yourfels: - `vm_context.heightmap = vm_context.heightmap or minetest.get_mapgen_object('heightmap')` - `biomemap`: mapgen object contanting biome IDs of nodes, - !NO ANY DATA LOADS INTO IT BEFORE THE CALLBACKS! - you load it yourfels: - `vm_context.biomemap = vm_context.biomemap or minetest.get_mapgen_object('biomemap')` - `heatmap`: mapgen object contanting temperature values of nodes, - !NO ANY DATA LOADS INTO IT BEFORE THE CALLBACKS! - you load it yourfels: - `vm_context.heatmap = vm_context.heatmap or minetest.get_mapgen_object('heatmap')` - `humiditymap`: mapgen object contanting humidity values of nodes, - !NO ANY DATA LOADS INTO IT BEFORE THE CALLBACKS! - you load it yourfels: - `vm_context.humiditymap = vm_context.humiditymap or minetest.get_mapgen_object('humiditymap')` - `gennotify`: mapgen object contanting mapping table of structures, see Minetest Lua API for explanation, - !NO ANY DATA LOADS INTO IT BEFORE THE CALLBACKS! - you load it yourfels: - `vm_context.gennotify = vm_context.gennotify or minetest.get_mapgen_object('gennotify')` - `priority` (optional): order number - the less, the earlier, - e.g. `mcl_mapgen.priorities.BUILDINGS` or `mcl_mapgen.priorities.LARGE_BUILDINGS` - -## mcl_mapgen.get_far_node(pos) -=============================== -Returns node if it is generated. Otherwise returns `{name = "ignore"}`. +# mcl_mapgen +============ +Helps to avoid problems caused by 'chunk-in-shell' feature of mapgen.cpp. +It also queues your generators to run them in proper order: + +### mcl_mapgen.register_on_generated(callback_function, order_number) +For Minetest 5.4 it doesn't recommended to place blocks within callback function. +See https://git.minetest.land/MineClone2/MineClone2/issues/1395 + `callback_function`: chunk callback LVM function definition: + `function(vm_context)`: + Function MUST RETURN `vm_context` back anyway! It will passed into next callback function from the queue. + `vm_context`: a table which already contains some LVM data if the fields, and some of them can be added by you right in the callback function: + `vm`: curent voxel manipulator object itself; + `blockseed`: seed of this mapchunk; + `minp` & `maxp`: minimum and maximum chunk position; + `emin` & `emax`: minimum and maximum chunk position WITH SHELL AROUND IT; + `area`: voxel area, can be helpful to access data; + `data`: LVM buffer data array, data loads into it before the callbacks; + `write`: set it to true in yout callback functionm, if you changed `data` and want to write it; + `data2`: LVM buffer data array of `param2`, !NO ANY DATA LOADS INTO IT BEFORE THE CALLBACKS! - you load it yourfels: + `vm_context.data2 = vm_context.data2 or vm_context.vm.get_param2_data(vm_context.lvm_param2_buffer)` + `write_param2`: set it to true in yout callback functionm, if you used `data2` and want to write it; + `lvm_param2_buffer`: static `param2` buffer pointer, used to load `data2` array; + `shadow`: set it to false to disable shadow propagation; + `heightmap`: mapgen object contanting y coordinates of ground level, + !NO ANY DATA LOADS INTO IT BEFORE THE CALLBACKS! - load it yourfels: + `vm_context.heightmap = vm_context.heightmap or minetest.get_mapgen_object('heightmap')` + `biomemap`: mapgen object contanting biome IDs of nodes, + !NO ANY DATA LOADS INTO IT BEFORE THE CALLBACKS! - load it yourfels: + `vm_context.biomemap = vm_context.biomemap or minetest.get_mapgen_object('biomemap')` + `heatmap`: mapgen object contanting temperature values of nodes, + !NO ANY DATA LOADS INTO IT BEFORE THE CALLBACKS! - load it yourfels: + `vm_context.heatmap = vm_context.heatmap or minetest.get_mapgen_object('heatmap')` + `humiditymap`: mapgen object contanting humidity values of nodes, + !NO ANY DATA LOADS INTO IT BEFORE THE CALLBACKS! - load it yourfels: + `vm_context.humiditymap = vm_context.humiditymap or minetest.get_mapgen_object('humiditymap')` + `gennotify`: mapgen object contanting mapping table of structures, see Minetest Lua API for explanation, + !NO ANY DATA LOADS INTO IT BEFORE THE CALLBACKS! - load it yourfels: + `vm_context.gennotify = vm_context.gennotify or minetest.get_mapgen_object('gennotify')` + `order_number` (optional): the less, the earlier, + e.g. `mcl_mapgen.order.BUILDINGS` or `mcl_mapgen.order.LARGE_BUILDINGS` + +### mcl_mapgen.register_mapgen(callback_function, order_number) +============================================================================== +Registers callback function to be called when current chunk generation is finished. + `callback_function`: callback function definition: + `function(minp, maxp, seed)`: + `minp` & `maxp`: minimum and maximum chunk position; + `seed`: seed of this mapchunk; + `order_number` (optional): the less, the earlier, + e.g. `mcl_mapgen.order.BUILDINGS` or `mcl_mapgen.order.LARGE_BUILDINGS` + +### mcl_mapgen.register_mapgen_block(callback_function, order_number) +======================================================================= +Registers callback function to be called when block (usually 16x16x16 nodes) generation is finished. + `callback_function`: callback function definition: + `function(minp, maxp, seed)`: + `minp` & `maxp`: minimum and maximum block position; + `seed`: seed of this mapblock; + `order_number` (optional): the less, the earlier, + e.g. `mcl_mapgen.order.BUILDINGS` or `mcl_mapgen.order.LARGE_BUILDINGS` + +### mcl_mapgen.register_mapgen_block_lvm(callback_function, order_number) +============================================================================ +Registers callback function to be called when block (usually 16x16x16 nodes) generation is finished. +`vm_context` passes into callback function and should be returned back. + `callback_function`: block callback LVM function definition, see below; + `order_number` (optional): the less, the earlier, + e.g. `mcl_mapgen.order.BUILDINGS` or `mcl_mapgen.order.LARGE_BUILDINGS` + +### mcl_mapgen.register_mapgen_lvm(callback_function, order_number) +============================================================================ + +### mcl_mapgen.get_far_node(pos) +=============================== +Returns node if it is generated. Otherwise returns `{name = "ignore"}`. + +## Constants: + +* `mcl_mapgen.EDGE_MIN`, `mcl_mapgen.EDGE_MAX` - world edges, min & max. +* `mcl_mapgen.seed`, `mcl_mapgen.name` - mapgen seed & name. +* `mcl_mapgen.v6`, `mcl_mapgen.superflat`, `mcl_mapgen.singlenode` - is mapgen v6, superflat, singlenode. +* `mcl_mapgen.normal` is mapgen normal (not superflat or singlenode). diff --git a/mods/CORE/mcl_mapgen/init.lua b/mods/CORE/mcl_mapgen/init.lua index 992c93b0d..7e49f5d11 100644 --- a/mods/CORE/mcl_mapgen/init.lua +++ b/mods/CORE/mcl_mapgen/init.lua @@ -1,6 +1,6 @@ mcl_mapgen = {} -local priorities = { -- mcl_mapgen.priorities... +local order = { -- mcl_mapgen.order... DEFAULT = 5000, CHORUS = 100000, BUILDINGS = 200000, @@ -43,12 +43,13 @@ local numcmax = math_max(math_floor((mapgen_limit_max - ccfmax) / mcl_mapgen.CS_ mcl_mapgen.EDGE_MIN = central_chunk_min_pos - numcmin * mcl_mapgen.CS_NODES mcl_mapgen.EDGE_MAX = central_chunk_max_pos + numcmax * mcl_mapgen.CS_NODES -minetest_log("action", "[mcl_mapgen] World edges are: mcl_mapgen.EDGE_MIN = " .. tostring(mcl_mapgen.EDGE_MIN) .. ", mcl_mapgen.EDGE_MAX = " .. tostring(mcl_mapgen.EDGE_MAX)) +minetest_log("action", "[mcl_mapgen] World edges: mcl_mapgen.EDGE_MIN = " .. tostring(mcl_mapgen.EDGE_MIN) .. ", mcl_mapgen.EDGE_MAX = " .. tostring(mcl_mapgen.EDGE_MAX)) ------------------------------------------ -- Mapgen variables local overworld, end_, nether = {}, {}, {} -mcl_mapgen.seed = minetest.get_mapgen_setting("seed") +local seed = minetest.get_mapgen_setting("seed") +mcl_mapgen.seed = seed mcl_mapgen.name = minetest.get_mapgen_setting("mg_name") mcl_mapgen.v6 = mcl_mapgen.name == "v6" mcl_mapgen.superflat = mcl_mapgen.name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true" @@ -59,9 +60,8 @@ local superflat, singlenode, normal = mcl_mapgen.superflat, mcl_mapgen.singlenod minetest_log("action", "[mcl_mapgen] Mapgen mode: " .. (normal and "normal" or (superflat and "superflat" or "singlenode"))) ------------------------------------------ -local lvm_block_queue, lvm_chunk_queue, node_block_queue, node_chunk_queue = {}, {}, {}, {} -- Generators' queues -local lvm, block, lvm_block, lvm_chunk, param2, nodes_block, nodes_chunk, safe_functions = 0, 0, 0, 0, 0, 0, 0, 0 -- Requirements: 0 means none; greater than 0 means 'required' -local lvm_buffer, lvm_param2_buffer = {}, {} -- Static buffer pointers +local queue_unsafe, queue_blocks_lvm, queue_lvm, queue_blocks, queue = {}, {}, {}, {}, {} -- Generators' queues +local lvm, block, queue_blocks_lvm_counter, lvm_chunk, param2, nodes_block, nodes_chunk, safe_functions = 0, 0, 0, 0, 0, 0, 0, 0 -- Requirements: 0 means none; greater than 0 means 'required' local BS, CS = mcl_mapgen.BS, mcl_mapgen.CS -- Mapblock size (in nodes), Mapchunk size (in blocks) local LAST_BLOCK, LAST_NODE = CS - 1, BS - 1 -- First mapblock in chunk (node in mapblock) has number 0, last has THIS number. It's for runtime optimization local offset = mcl_mapgen.OFFSET -- Central mapchunk offset (in blocks) @@ -69,59 +69,39 @@ local CS_NODES = mcl_mapgen.CS_NODES -- 80 local CS_3D = CS * CS * CS -local DEFAULT_PRIORITY = priorities.DEFAULT +local DEFAULT_ORDER = order.DEFAULT -function mcl_mapgen.register_chunk_generator(callback_function, priority) +function mcl_mapgen.register_on_generated(callback_function, order) + queue_unsafe[#queue_unsafe+1] = {i = priority or DEFAULT_ORDER, f = callback_function} + table.sort(queue_lvm, function(a, b) return (a.i <= b.i) end) +end +function mcl_mapgen.register_mapgen(callback_function, order) nodes_chunk = nodes_chunk + 1 safe_functions = safe_functions + 1 - node_chunk_queue[nodes_chunk] = {i = priority or DEFAULT_PRIORITY, f = callback_function} - table.sort(node_chunk_queue, function(a, b) return (a.i <= b.i) end) + queue[nodes_chunk] = {i = order or DEFAULT_ORDER, f = callback_function} + table.sort(queue, function(a, b) return (a.i <= b.i) end) end -function mcl_mapgen.register_chunk_generator_lvm(callback_function, priority) +function mcl_mapgen.register_mapgen_lvm(callback_function, order) lvm = lvm + 1 - lvm_chunk_queue[lvm_chunk] = {i = priority or DEFAULT_PRIORITY, f = callback_function} - table.sort(lvm_chunk_queue, function(a, b) return (a.i <= b.i) end) + lvm_chunk = lvm_chunk + 1 + safe_functions = safe_functions + 1 + queue_lvm[lvm_chunk] = {i = priority or DEFAULT_ORDER, f = callback_function} + table.sort(queue_lvm, function(a, b) return (a.i <= b.i) end) end -function mcl_mapgen.register_block_generator(callback_function, priority) +function mcl_mapgen.register_mapgen_block(callback_function, priority) block = block + 1 nodes_block = nodes_block + 1 safe_functions = safe_functions + 1 - node_block_queue[nodes_block] = {i = priority or DEFAULT_PRIORITY, f = callback_function} - table.sort(node_block_queue, function(a, b) return (a.i <= b.i) end) + queue_blocks[nodes_block] = {i = priority or DEFAULT_ORDER, f = callback_function} + table.sort(queue_blocks, function(a, b) return (a.i <= b.i) end) end -function mcl_mapgen.register_block_generator_lvm(callback_function, priority) +function mcl_mapgen.register_mapgen_block_lvm(callback_function, order) block = block + 1 lvm = lvm + 1 - lvm_block = lvm_block + 1 - lvm_block_queue[lvm_block] = {i = priority or DEFAULT_PRIORITY, f = callback_function} - table.sort(lvm_block_queue, function(a, b) return (a.i <= b.i) end) -end - -function mcl_mapgen.get_block_seed(pos, seed) - local p = pos - local x, y, z = p.x, p.y, p.z - if x<0 then x = 4294967296+x end - if y<0 then y = 4294967296+y end - if z<0 then z = 4294967296+z end - local seed = (seed or mcl_mapgen.seed or 0) % 4294967296 - return (seed + (z*38134234)%4294967296 + (y*42123)%4294967296 + (x*23)%4294967296) % 4294967296 -end - -function mcl_mapgen.get_block_seed_2(pos, seed) - local p = pos - local seed = seed or mcl_mapgen.seed or 0 - local x, y, z = p.x, p.y, p.z - if x<0 then x = 4294967296+x end - if y<0 then y = 4294967296+y end - if z<0 then z = 4294967296+z end - local n = ((1619*x)%4294967296 + (31337*y)%4294967296 + (52591*z)%4294967296 + (1013*seed)%4294967296) % 4294967296 --- n = (math_floor(n / 8192) ^ n) % 4294967296 - - local m = (n*n) % 4294967296 - m = (m*60493) % 4294967296 - m = (m+19990303) % 4294967296 - - return (n * m + 1376312589) % 4294967296 + queue_blocks_lvm_counter =queue_blocks_lvm_counter + 1 + safe_functions = safe_functions + 1 + queue_blocks_lvm[queue_blocks_lvm_counter] = {order = order or DEFAULT_ORDER, callback_function = callback_function} + table.sort(queue_blocks_lvm, function(a, b) return (a.order <= b.order) end) end local storage = minetest.get_mod_storage() @@ -132,37 +112,44 @@ minetest.register_on_shutdown(function() storage:set_string("mapgen_blocks", minetest.serialize(blocks)) end) -local vm_context-- here will be many references and flags, like: param2, light_data, heightmap, biomemap, heatmap, humiditymap, gennotify, write_lvm, write_param2, shadow +local vm_context -- here will be many references and flags, like: param2, light_data, heightmap, biomemap, heatmap, humiditymap, gennotify, write_lvm, write_param2, shadow local data, data2, area local current_blocks = {} local current_chunks = {} +local lvm_buffer, lvm_param2_buffer = {}, {} -- Static buffer pointers -minetest.register_on_generated(function(minp, maxp, blockseed) - local minp, maxp, blockseed = minp, maxp, blockseed +minetest.register_on_generated(function(minp, maxp, chunkseed) + local minp, maxp, chunkseed = minp, maxp, chunkseed local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") - minetest_log("warning", "[mcl_mapgen] New_chunk=" .. minetest_pos_to_string(minp) .. "..." .. minetest_pos_to_string(maxp) .. ", shell=" .. minetest_pos_to_string(emin) .. "..." .. minetest_pos_to_string(emax) .. ", blockseed=" .. tostring(blockseed) .. ", seed1=" .. mcl_mapgen.get_block_seed(minp) .. ", seed2=" .. mcl_mapgen.get_block_seed_2(minp)) + minetest_log("warning", "[mcl_mapgen] New_chunk=" .. minetest_pos_to_string(minp) .. "..." .. minetest_pos_to_string(maxp) .. ", shell=" .. minetest_pos_to_string(emin) .. "..." .. minetest_pos_to_string(emax) .. ", chunkseed=" .. tostring(chunkseed)) - if lvm > 0 then - vm_context = {lvm_param2_buffer = lvm_param2_buffer, vm = vm, emin = emin, emax = emax, minp = minp, maxp = maxp, blockseed = blockseed} - data = vm:get_data(lvm_buffer) - vm_context.data = data - area = VoxelArea:new({MinEdge=emin, MaxEdge=emax}) - vm_context.area = area - end + data = vm:get_data(lvm_buffer) + area = VoxelArea:new({MinEdge=emin, MaxEdge=emax}) + vm_context = { + data = data, + area = area, + lvm_param2_buffer = lvm_param2_buffer, + vm = vm, + emin = emin, + emax = emax, + minp = minp, + maxp = maxp, + chunkseed = chunkseed + } if safe_functions > 0 then local x0, y0, z0 = minp.x, minp.y, minp.z local bx0, by0, bz0 = math_floor(x0/BS), math_floor(y0/BS), math_floor(z0/BS) local bx1, by1, bz1 = bx0 + LAST_BLOCK, by0 + LAST_BLOCK, bz0 + LAST_BLOCK -- only for entire chunk check - -- Keep `blockseed` in `chunks[cx][cy][cz].seed` for further safe usage: + -- Keep `chunkseed` in `chunks[cx][cy][cz].seed` for further safe usage: local cx0, cy0, cz0 = math_floor((bx0-offset)/CS), math_floor((by0-offset)/CS), math_floor((bz0-offset)/CS) if not chunks[cx0] then chunks[cx0] = {} end if not chunks[cx0][cy0] then chunks[cx0][cy0] = {} end if not chunks[cx0][cy0][cz0] then - chunks[cx0][cy0][cz0] = {seed = blockseed, counter = 0} + chunks[cx0][cy0][cz0] = {seed = chunkseed, counter = 0} else - chunks[cx0][cy0][cz0].seed = blockseed + chunks[cx0][cy0][cz0].seed = chunkseed end local x1, y1, z1, x2, y2, z2 = emin.x, emin.y, emin.z, emax.x, emax.y, emax.z @@ -233,15 +220,16 @@ minetest.register_on_generated(function(minp, maxp, blockseed) if next(chunks[cx]) == nil then chunks[cx] = nil end end end - vm_context.seed = blockseed + box * 7 + boy * 243 + boz * 11931 - if lvm_block > 0 then - vm_context.minp, vm_content.maxp = {x=x, y=y, z=z}, {x=x+LAST_NODE, y=y+LAST_NODE, z=z+LAST_NODE} - for _, v in pairs(lvm_block_queue) do - vm_context = v.f(vm_context) + local blockseed = seed + bx * 7 + by * 243 + bz * 11931 + if queue_blocks_lvm_counter > 0 then + vm_context.blockseed = blockseed + vm_context.minp, vm_context.maxp = {x=x, y=y, z=z}, {x=x+LAST_NODE, y=y+LAST_NODE, z=z+LAST_NODE} + for _, v in pairs(queue_blocks_lvm) do + vm_context = v.callback_function(vm_context) end end if nodes_block > 0 then - current_blocks[#current_blocks+1] = { minp = {x=x, y=y, z=z}, maxp = {x=pos.x+LAST_NODE, y=pos.y+LAST_NODE, z=pos.z+LAST_NODE}, seed = seed } + current_blocks[#current_blocks+1] = { minp = {x=x, y=y, z=z}, maxp = {x=x+LAST_NODE, y=y+LAST_NODE, z=z+LAST_NODE}, seed = blockseed } end else blocks[bx][by][bz] = current_mapgen_block_writes @@ -259,7 +247,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed) end if lvm > 0 then - for _, v in pairs(lvm_chunk_queue) do + for _, v in pairs(queue_lvm) do vm_context = v.f(vm_context) end if vm_context.write then @@ -279,14 +267,14 @@ minetest.register_on_generated(function(minp, maxp, blockseed) local x, y, z = bx * BS, by * BS, bz * BS local minp = {x = x, y = y, z = z} local maxp = {x = x + CS_NODES - 1, y = y + CS_NODES - 1, z = z + CS_NODES - 1} - for _, v in pairs(node_chunk_queue) do + for _, v in pairs(queue) do v.f(minp, maxp, seed) end current_chunks[i] = nil end for i, b in pairs(current_blocks) do - for _, v in pairs(node_block_queue) do + for _, v in pairs(queue_blocks) do v.f(b.minp, b.maxp, b.seed) end current_blocks[i] = nil @@ -386,11 +374,11 @@ else end if mcl_mapgen.name == "flat" then if superflat then - nether.flat_nether_floor = nether.bedrock_bottom_max + 4 - nether.flat_nether_ceiling = nether.bedrock_bottom_max + 52 + nether.flat_floor = nether.bedrock_bottom_max + 4 + nether.flat_ceiling = nether.bedrock_bottom_max + 52 else - nether.flat_nether_floor = nether.lava_max + 4 - nether.flat_nether_ceiling = nether.lava_max + 52 + nether.flat_floor = nether.lava_max + 4 + nether.flat_ceiling = nether.lava_max + 52 end end @@ -410,4 +398,4 @@ mcl_mapgen.overworld = overworld mcl_mapgen.end_ = end_ mcl_mapgen.nether = nether -mcl_mapgen.priorities = priorities +mcl_mapgen.order = order diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index 95b673aa2..10a5f2414 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -3990,15 +3990,15 @@ if not mcl_mapgen.singlenode then -- Overworld decorations for v6 are handled in mcl_mapgen_core if deco_id_chorus_plant then - mcl_mapgen.register_chunk_generator_lvm(function(c) - c.gennotify = c.gennotify or minetest.get_mapgen_object("gennotify") - local gennotify = c.gennotify + mcl_mapgen.register_mapgen_block_lvm(function(vm_context) + vm_context.gennotify = vm_context.gennotify or minetest.get_mapgen_object("gennotify") + local gennotify = vm_context.gennotify for _, pos in pairs(gennotify["decoration#"..deco_id_chorus_plant] or {}) do local realpos = { x = pos.x, y = pos.y + 1, z = pos.z } minetest.after(1, mcl_end.grow_chorus_plant, realpos) end - return c - end, mcl_mapgen.priorities.CHORUS) + return vm_context + end, mcl_mapgen.order.CHORUS) end end diff --git a/mods/MAPGEN/mcl_debrisgen/init.lua b/mods/MAPGEN/mcl_debrisgen/init.lua index 28af327cd..b2b630626 100644 --- a/mods/MAPGEN/mcl_debrisgen/init.lua +++ b/mods/MAPGEN/mcl_debrisgen/init.lua @@ -1,45 +1,33 @@ -local c_debris = minetest.get_content_id("mcl_nether:ancient_debris") -local c_netherrack = minetest.get_content_id("mcl_nether:netherrack") -local c_air = minetest.get_content_id("air") - -local facedir = { - vector.new(0, 0, 1), - vector.new(0, 1, 0), - vector.new(1, 0, 0), - vector.new(0, 0, -1), - vector.new(0, -1, 0), - vector.new(-1, 0, 0), -} +local minetest_find_nodes_in_area = minetest.find_nodes_in_area +local minetest_get_node = minetest.get_node +local minetest_set_node = minetest.set_node +local debris_name = "mcl_nether:ancient_debris" +local netherrack_name = "mcl_nether:netherrack" +local air_name = "air" local min, max = mcl_mapgen.nether.min, mcl_mapgen.nether.max -minetest.register_on_generated(function(minp, maxp) - if maxp.y < min or minp.y > max then - return - end - - local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") - local data = vm:get_data() - local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax}) - - for idx in area:iter(minp.x, math.max(minp.y, min), minp.z, maxp.x, math.min(maxp.y, max), maxp.z) do - if data[idx] == c_debris then - local pos = area:position(idx) - local exposed = false - for _, dir in pairs(facedir) do - if data[area:indexp(vector.add(pos, dir))] == c_air then - exposed = true - break - end - end - if exposed then - data[idx] = c_netherrack - end - end - end - - vm:set_data(data) - vm:calc_lighting() - vm:update_liquids() - vm:write_to_map() +mcl_mapgen.register_mapgen_block(function(minp, maxp) + local minp = minp + local minp_y = minp.y + if minp_y > max then return end + local maxp = maxp + local maxp_y = maxp.y + if maxp_y < min then return end + local nodes = minetest_find_nodes_in_area(minp, maxp, debris_name) + if nodes then + for _, pos in pairs(nodes) do + minetest.log("warning","debris found at "..minetest.pos_to_string(pos)) + local x, y, z = pos.x, pos.y, pos.z + if minetest_get_node({x = x-1, y = y, z = z}) == air_name + or minetest_get_node({x = x+1, y = y, z = z}) == air_name + or minetest_get_node({x = x, y = y-1, z = z}) == air_name + or minetest_get_node({x = x, y = y+1, z = z}) == air_name + or minetest_get_node({x = x, y = y, z = z-1}) == air_name + or minetest_get_node({x = x, y = y, z = z+1}) == air_name then + minetest_set_node(pos, netherrack_name) + minetest.log("warning","debris at "..minetest.pos_to_string(pos) .. " replaced to netherrack") + end + end + end end) diff --git a/mods/MAPGEN/mcl_debrisgen/mod.conf b/mods/MAPGEN/mcl_debrisgen/mod.conf index 270f40f71..9407fedc9 100644 --- a/mods/MAPGEN/mcl_debrisgen/mod.conf +++ b/mods/MAPGEN/mcl_debrisgen/mod.conf @@ -1,4 +1,4 @@ name = mcl_debrisgen author = Fleckenstein description = Make sure ancient debris is not generated exposed to air -depends = mcl_mapgen, mcl_mapgen_core, mcl_nether +depends = mcl_mapgen, mcl_nether diff --git a/mods/MAPGEN/mcl_dungeons/init.lua b/mods/MAPGEN/mcl_dungeons/init.lua index b333f4d8a..c4228d2cf 100644 --- a/mods/MAPGEN/mcl_dungeons/init.lua +++ b/mods/MAPGEN/mcl_dungeons/init.lua @@ -9,6 +9,7 @@ end --lua locals --minetest +local minetest_find_nodes_in_area = minetest.find_nodes_in_area local registered_nodes = minetest.registered_nodes local swap_node = minetest.swap_node local set_node = minetest.set_node @@ -64,6 +65,7 @@ local surround_vectors = { -- if calls_remaining >= 1 then return end -- local p1, _, dim, pr = param.p1, param.p2, param.dim, param.pr -- local check = not (param.dontcheck or false) +local m1, m2 = 0, 0 local function spawn_dungeon(p1, p2, dim, pr, dontcheck) local x, y, z = p1.x, p1.y, p1.z @@ -72,10 +74,40 @@ local function spawn_dungeon(p1, p2, dim, pr, dontcheck) -- Check floor and ceiling: Must be *completely* solid local y_floor = y local y_ceiling = y + dim.y + 1 - if check then for tx = x+1, x+dim.x do for tz = z+1, z+dim.z do - if not registered_nodes[get_node({x = tx, y = y_floor , z = tz}).name].walkable - or not registered_nodes[get_node({x = tx, y = y_ceiling, z = tz}).name].walkable then return false end - end end end + + if check then + local result1, result2 = true, true + local dim_x, dim_z = dim.x, dim.z + local size = dim_z*dim_x + local time1 = minetest.get_us_time() + for i=1,100 do + for tx = x+1, x+dim_x do + for tz = z+1, z+dim_z do + if not registered_nodes[get_node({x = tx, y = y_floor , z = tz}).name].walkable + or not registered_nodes[get_node({x = tx, y = y_ceiling, z = tz}).name].walkable then + result1 = false + end + end + end + end + local time2 = minetest.get_us_time() + for i=1,100 do + if #minetest_find_nodes_in_area({x=x+1,y=y_floor,z=z+1}, {x=x+dim_z,y=y_floor,z=z+dim_z}, "group:walkabke") < size + or #minetest_find_nodes_in_area({x=x+1,y=y_floor,z=z+1}, {x=x+dim_z,y=y_floor,z=z+dim_z}, "group:walkabke") < size then + result2 = false + end + end + local time3 = minetest.get_us_time() + if result1 == result2 then + local d1, d2 = time2-time1, time3-time2 + local m1 = m1 + d1 + local m2 = m2 + d2 + minetest.chat_send_all("m1 = " .. tostring(m1)) + minetest.chat_send_all("m2 = " .. tostring(m2)) + else + minetest.log("warning", "results mismatch") + end + end -- Check for air openings (2 stacked air at ground level) in wall positions local openings_counter = 0 @@ -413,4 +445,4 @@ function mcl_dungeons.spawn_dungeon(p1, _, pr) spawn_dungeon(p1, p2, dim, pr, true) end -mcl_mapgen.register_chunk_generator(dungeons_nodes, mcl_mapgen.priorities.DUNGEONS) +mcl_mapgen.register_mapgen(dungeons_nodes, mcl_mapgen.order.DUNGEONS) diff --git a/mods/MAPGEN/mcl_end_island/init.lua b/mods/MAPGEN/mcl_end_island/init.lua index 730176257..b0e5e68eb 100644 --- a/mods/MAPGEN/mcl_end_island/init.lua +++ b/mods/MAPGEN/mcl_end_island/init.lua @@ -10,7 +10,7 @@ local noisemap = PerlinNoiseMap({ local c_end_stone = minetest.get_content_id("mcl_end:end_stone") local y_offset = -2 -minetest.register_on_generated(function(minp, maxp) +mcl_mapgen.register_mapgen(function(minp, maxp) if maxp.y < (-27025 + y_offset) or minp.y > (-27000 + y_offset + 4) or maxp.x < -75 or minp.x > 75 or maxp.z < -75 or minp.z > 75 then return end diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 10ab43ae5..f306c608e 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -784,7 +784,7 @@ local function register_mgv6_decorations() persist = 0.62, }, y_min = 1, - y_max = mcl_vars.overworld_max, + y_max = mcl_mapgen.overworld.max, flags = "", }) end @@ -837,7 +837,7 @@ local function register_mgv6_decorations() persist = 0.666 }, y_min = 1, - y_max = mcl_vars.overworld_max, + y_max = mcl_mapgen.overworld.max, }) -- Melon @@ -875,7 +875,7 @@ local function register_mgv6_decorations() persist = 0.6 }, y_min = 1, - y_max = mcl_vars.overworld_max, + y_max = mcl_mapgen.overworld.max, decoration = "mcl_flowers:tallgrass", }) minetest.register_decoration({ @@ -891,7 +891,7 @@ local function register_mgv6_decorations() persist = 0.6 }, y_min = 1, - y_max = mcl_vars.overworld_max, + y_max = mcl_mapgen.overworld.max, decoration = "mcl_flowers:tallgrass", }) @@ -916,7 +916,7 @@ local function register_mgv6_decorations() }, flags = "force_placement", place_offset_y = -1, - y_min = mcl_vars.overworld_min, + y_min = mcl_mapgen.overworld.min, y_max = 0, decoration = "mcl_ocean:seagrass_"..mat, }) @@ -936,7 +936,7 @@ local function register_mgv6_decorations() }, flags = "force_placement", place_offset_y = -1, - y_min = mcl_vars.overworld_min, + y_min = mcl_mapgen.overworld.min, y_max = -5, decoration = "mcl_ocean:seagrass_"..mat, }) @@ -957,7 +957,7 @@ local function register_mgv6_decorations() }, flags = "force_placement", place_offset_y = -1, - y_min = mcl_vars.overworld_min, + y_min = mcl_mapgen.overworld.min, y_max = -6, decoration = "mcl_ocean:kelp_"..mat, param2 = 16, @@ -979,7 +979,7 @@ local function register_mgv6_decorations() }, flags = "force_placement", place_offset_y = -1, - y_min = mcl_vars.overworld_min, + y_min = mcl_mapgen.overworld.min, y_max = -15, decoration = "mcl_ocean:kelp_"..mat, param2 = 32, @@ -1017,7 +1017,7 @@ local function register_mgv6_decorations() sidelen = 8, fill_ratio = 0.004, y_min = 1, - y_max = mcl_vars.overworld_max, + y_max = mcl_mapgen.overworld.max, decoration = "mcl_flowers:tallgrass", }) @@ -1120,7 +1120,7 @@ end local mg_flags = minetest.settings:get_flags("mg_flags") -- Inform other mods of dungeon setting for MCL2-style dungeons -mcl_vars.mg_dungeons = mg_flags.dungeons and not superflat +mcl_vars.mg_dungeons = mcl_mapgen.dungeons -- Disable builtin dungeons, we provide our own dungeons mg_flags.dungeons = false @@ -1191,8 +1191,8 @@ local perlin_vines, perlin_vines_fine, perlin_vines_upwards, perlin_vines_length local perlin_clay -- Generate Clay -mcl_mapgen.register_chunk_generator_lvm(function(c) - local minp, maxp, blockseed, voxelmanip_data, voxelmanip_area, lvm_used = c.minp, c.maxp, c.blockseed, c.data, c.area, c.write or false +mcl_mapgen.register_mapgen_lvm(function(c) + local minp, maxp, blockseed, voxelmanip_data, voxelmanip_area, lvm_used = c.minp, c.maxp, c.chunkseed, c.data, c.area, c.write or false -- TODO: Make clay generation reproducible for same seed. if maxp.y < -5 or minp.y > 0 then return c @@ -1799,7 +1799,7 @@ local function generate_nether_decorations(minp, maxp, seed) -- Note: Spawned *after* the fire because of light level checks special_deco(rack, function(bpos) local l = minetest.get_node_light(bpos, 0.5) - if bpos.y > mcl_vars.mg_lava_nether_max + 6 and l and l <= 12 and pr_nether:next(1,1000) <= 4 then + if bpos.y > mcl_mapgen.nether.lava_max + 6 and l and l <= 12 and pr_nether:next(1,1000) <= 4 then -- TODO: Make mushrooms appear in groups, use Perlin noise if pr_nether:next(1,2) == 1 then minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_brown"}) @@ -1823,15 +1823,15 @@ end -- Also perform some basic node replacements. local bedrock_check -if mcl_vars.mg_bedrock_is_rough then +if mcl_mapgen.bedrock_is_rough then function bedrock_check(pos, _, pr) local y = pos.y -- Bedrock layers with increasing levels of roughness, until a perfecly flat bedrock later at the bottom layer -- This code assumes a bedrock height of 5 layers. - local diff = mcl_vars.mg_bedrock_overworld_max - y -- Overworld bedrock - local ndiff1 = mcl_vars.mg_bedrock_nether_bottom_max - y -- Nether bedrock, bottom - local ndiff2 = mcl_vars.mg_bedrock_nether_top_max - y -- Nether bedrock, ceiling + local diff = mcl_mapgen.overworld.bedrock_max - y -- Overworld bedrock + local ndiff1 = mcl_mapgen.nether.bedrock_bottom_max - y -- Nether bedrock, bottom + local ndiff2 = mcl_mapgen.nether.bedrock_top_max - y -- Nether bedrock, ceiling local top if diff == 0 or ndiff1 == 0 or ndiff2 == 4 then @@ -1895,10 +1895,10 @@ local function set_layers(data, area, content_id, check, min, max, minp, maxp, l end -- Below the bedrock, generate air/void -local function basic(c) - local vm, data, emin, emax, area, minp, maxp, blockseed = c.vm, c.data, c.emin, c.emax, c.area, c.minp, c.maxp, c.blockseed - c.data2 = c.data2 or vm:get_data_param2(lvm_buffer_param2) - local data2 = c.data2 +local function basic_safe(vm_context) + local vm, data, emin, emax, area, minp, maxp, chunkseed, blockseed = vm_context.vm, vm_context.data, vm_context.emin, vm_context.emax, vm_context.area, vm_context.minp, vm_context.maxp, vm_context.chunkseed, vm_context.blockseed + vm_context.data2 = vm_context.data2 or vm:get_param2_data(lvm_param2_buffer) + local data2 = vm_context.data2 local lvm_used = false local pr = PseudoRandom(blockseed) @@ -1916,34 +1916,35 @@ local function basic(c) -- [[ THE END: mcl_mapgen.end_.min mcl_mapgen.end_.max ]] -- The Void above the End below the Realm barrier: - lvm_used = set_layers(data, area, c_void , nil, mcl_mapgen.end_.max +1, mcl_vars.mg_realm_barrier_overworld_end_min-1, minp, maxp, lvm_used, pr) + lvm_used = set_layers(data, area, c_void , nil, mcl_mapgen.end_.max +1, mcl_mapgen.realm_barrier_overworld_end_min-1, minp, maxp, lvm_used, pr) -- Realm barrier between the Overworld void and the End - lvm_used = set_layers(data, area, c_realm_barrier, nil, mcl_vars.mg_realm_barrier_overworld_end_min , mcl_vars.mg_realm_barrier_overworld_end_max , minp, maxp, lvm_used, pr) + lvm_used = set_layers(data, area, c_realm_barrier, nil, mcl_mapgen.realm_barrier_overworld_end_min , mcl_mapgen.realm_barrier_overworld_end_max , minp, maxp, lvm_used, pr) -- The Void above Realm barrier below the Overworld: - lvm_used = set_layers(data, area, c_void , nil, mcl_vars.mg_realm_barrier_overworld_end_max+1, mcl_mapgen.overworld.min -1, minp, maxp, lvm_used, pr) + lvm_used = set_layers(data, area, c_void , nil, mcl_mapgen.realm_barrier_overworld_end_max+1, mcl_mapgen.overworld.min -1, minp, maxp, lvm_used, pr) if mg_name ~= "singlenode" then -- Bedrock - lvm_used = set_layers(data, area, c_bedrock, bedrock_check, mcl_vars.mg_bedrock_overworld_min, mcl_vars.mg_bedrock_overworld_max, minp, maxp, lvm_used, pr) - lvm_used = set_layers(data, area, c_bedrock, bedrock_check, mcl_vars.mg_bedrock_nether_bottom_min, mcl_vars.mg_bedrock_nether_bottom_max, minp, maxp, lvm_used, pr) - lvm_used = set_layers(data, area, c_bedrock, bedrock_check, mcl_vars.mg_bedrock_nether_top_min, mcl_vars.mg_bedrock_nether_top_max, minp, maxp, lvm_used, pr) + lvm_used = set_layers(data, area, c_bedrock, bedrock_check, mcl_mapgen.overworld.bedrock_min, mcl_mapgen.overworld.bedrock_max, minp, maxp, lvm_used, pr) + lvm_used = set_layers(data, area, c_bedrock, bedrock_check, mcl_mapgen.nether.bedrock_bottom_min, mcl_mapgen.nether.bedrock_bottom_max, minp, maxp, lvm_used, pr) + lvm_used = set_layers(data, area, c_bedrock, bedrock_check, mcl_mapgen.nether.bedrock_top_min, mcl_mapgen.nether.bedrock_top_max, minp, maxp, lvm_used, pr) -- Flat Nether if mg_name == "flat" then - lvm_used = set_layers(data, area, c_air, nil, mcl_vars.mg_flat_nether_floor, mcl_vars.mg_flat_nether_ceiling, minp, maxp, lvm_used, pr) + lvm_used = set_layers(data, area, c_air, nil, mcl_mapgen.nether.flat_floor, mcl_mapgen.nether.flat_ceiling, minp, maxp, lvm_used, pr) end -- Big lava seas by replacing air below a certain height - if mcl_vars.mg_lava then + if mcl_mapgen.lava then lvm_used = set_layers(data, area, c_lava, c_air, mcl_mapgen.overworld.min, mcl_mapgen.overworld.lava_max, minp, maxp, lvm_used, pr) - lvm_used = set_layers(data, area, c_nether_lava, c_air, mcl_mapgen.nether.min, mcl_vars.mg_lava_nether_max, minp, maxp, lvm_used, pr) + lvm_used = set_layers(data, area, c_nether_lava, c_air, mcl_mapgen.nether.min, mcl_mapgen.nether.lava_max, minp, maxp, lvm_used, pr) end -- Clay, vines, cocoas - lvm_used = generate_clay(minp, maxp, blockseed, data, area, lvm_used) + -- lvm_used = generate_clay(minp, maxp, chunkseed, data, area, lvm_used) - c.biomemap = c.biomemap or minetest.get_mapgen_object("biomemap") + vm_context.biomemap = vm_context.biomemap or minetest.get_mapgen_object("biomemap") + local biomemap = vm_context.biomemap lvm_used = generate_tree_decorations(minp, maxp, blockseed, data, data2, area, biomemap, lvm_used, pr) @@ -2061,18 +2062,18 @@ local function basic(c) end -- Obsidian spawn platform - if minp.y <= mcl_vars.mg_end_platform_pos.y and maxp.y >= mcl_vars.mg_end_platform_pos.y and - minp.x <= mcl_vars.mg_end_platform_pos.x and maxp.x >= mcl_vars.mg_end_platform_pos.z and - minp.z <= mcl_vars.mg_end_platform_pos.z and maxp.z >= mcl_vars.mg_end_platform_pos.z then + if minp.y <= mcl_mapgen.end_.platform_pos.y and maxp.y >= mcl_mapgen.end_.platform_pos.y and + minp.x <= mcl_mapgen.end_.platform_pos.x and maxp.x >= mcl_mapgen.end_.platform_pos.z and + minp.z <= mcl_mapgen.end_.platform_pos.z and maxp.z >= mcl_mapgen.end_.platform_pos.z then - --local pos1 = {x = math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), y = math.max(minp.y, mcl_vars.mg_end_platform_pos.y), z = math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2)} - --local pos2 = {x = math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2), y = math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2), z = math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2)} + --local pos1 = {x = math.max(minp.x, mcl_mapgen.end_.platform_pos.x-2), y = math.max(minp.y, mcl_mapgen.end_.platform_pos.y), z = math.max(minp.z, mcl_mapgen.end_.platform_pos.z-2)} + --local pos2 = {x = math.min(maxp.x, mcl_mapgen.end_.platform_pos.x+2), y = math.min(maxp.y, mcl_mapgen.end_.platform_pos.y+2), z = math.min(maxp.z, mcl_mapgen.end_.platform_pos.z+2)} - for x=math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2) do - for z=math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2), math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2) do - for y=math.max(minp.y, mcl_vars.mg_end_platform_pos.y), math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2) do + for x=math.max(minp.x, mcl_mapgen.end_.platform_pos.x-2), math.min(maxp.x, mcl_mapgen.end_.platform_pos.x+2) do + for z=math.max(minp.z, mcl_mapgen.end_.platform_pos.z-2), math.min(maxp.z, mcl_mapgen.end_.platform_pos.z+2) do + for y=math.max(minp.y, mcl_mapgen.end_.platform_pos.y), math.min(maxp.y, mcl_mapgen.end_.platform_pos.y+2) do local p_pos = area:index(x, y, z) - if y == mcl_vars.mg_end_platform_pos.y then + if y == mcl_mapgen.end_.platform_pos.y then data[p_pos] = c_obsidian else data[p_pos] = c_air @@ -2104,8 +2105,7 @@ local function basic(c) generate_structures(minp, maxp, blockseed, biomemap) end - return lvm_used, shadow + return vm_context --, lvm_used, shadow end -mcl_mapgen.register_chunk_generator_lvm(basic, 1) - +mcl_mapgen.register_mapgen_block_lvm(basic_safe, 1) diff --git a/mods/MAPGEN/mcl_ocean_monument/init.lua b/mods/MAPGEN/mcl_ocean_monument/init.lua index 04117d143..fffa6f6b0 100644 --- a/mods/MAPGEN/mcl_ocean_monument/init.lua +++ b/mods/MAPGEN/mcl_ocean_monument/init.lua @@ -39,7 +39,7 @@ end local y_wanted = mcl_mapgen.OFFSET_NODES -- supposed to be -32 local y_bottom = mcl_mapgen.overworld.min -- -62 -mcl_mapgen.register_chunk_generator(function(minp, maxp, seed) +mcl_mapgen.register_mapgen(function(minp, maxp, seed) local minp = minp local y = minp.y if y ~= y_wanted then return end @@ -94,4 +94,4 @@ mcl_mapgen.register_chunk_generator(function(minp, maxp, seed) minetest_log("action", "[mcl_ocean_monument] Placed at " .. minetest_pos_to_string(minp) .. ", " .. rotation_str .. " deg.") -end, mcl_mapgen.priorities.OCEAN_MONUMENT) +end, mcl_mapgen.order.OCEAN_MONUMENT) diff --git a/mods/MAPGEN/mcl_strongholds/init.lua b/mods/MAPGEN/mcl_strongholds/init.lua index 26ab031af..db48a93ae 100644 --- a/mods/MAPGEN/mcl_strongholds/init.lua +++ b/mods/MAPGEN/mcl_strongholds/init.lua @@ -68,7 +68,7 @@ end init_strongholds() -- Stronghold generation for register_on_generated. -mcl_mapgen.register_chunk_generator(function(minp, maxp, blockseed) +mcl_mapgen.register_mapgen(function(minp, maxp, blockseed) local pr = PseudoRandom(blockseed) for s=1, #strongholds do if not strongholds[s].generated then @@ -100,4 +100,4 @@ mcl_mapgen.register_chunk_generator(function(minp, maxp, blockseed) end end end -end, mcl_mapgen.priorities.STRONGHOLDS) +end, mcl_mapgen.order.STRONGHOLDS) diff --git a/mods/MAPGEN/mcl_villages/init.lua b/mods/MAPGEN/mcl_villages/init.lua index 233e5a5ac..47ca91f2e 100644 --- a/mods/MAPGEN/mcl_villages/init.lua +++ b/mods/MAPGEN/mcl_villages/init.lua @@ -75,7 +75,7 @@ end -- Disable natural generation in singlenode. local mg_name = minetest.get_mapgen_setting("mg_name") if mg_name ~= "singlenode" then - mcl_mapgen.register_chunk_generator(function(minp, maxp, blockseed) + mcl_mapgen.register_mapgen(function(minp, maxp, blockseed) -- local str1 = (maxp.y >= 0 and blockseed % 77 == 17) and "YES" or "no" -- minetest.log("action","[mcl_villages] " .. str1 .. ": minp=" .. minetest.pos_to_string(minp) .. ", maxp=" .. minetest.pos_to_string(maxp) .. ", blockseed=" .. tostring(blockseed)) -- don't build settlement underground @@ -103,7 +103,7 @@ if mg_name ~= "singlenode" then if height_difference > max_height_difference then return end build_a_settlement(minp, maxp, blockseed) - end, mcl_mapgen.priorities.VILLAGES) + end, mcl_mapgen.order.VILLAGES) end -- manually place villages if minetest.is_creative_enabled("") then diff --git a/mods/MAPGEN/tsm_railcorridors/init.lua b/mods/MAPGEN/tsm_railcorridors/init.lua index 34bd455e3..654a05672 100644 --- a/mods/MAPGEN/tsm_railcorridors/init.lua +++ b/mods/MAPGEN/tsm_railcorridors/init.lua @@ -1092,7 +1092,7 @@ local function create_corridor_system(main_cave_coords) end -- The rail corridor algorithm starts here -mcl_mapgen.register_chunk_generator(function(minp, maxp, blockseed, _pr) +mcl_mapgen.register_mapgen(function(minp, maxp, blockseed) -- We re-init the randomizer for every mapchunk as we start generating in the middle of each mapchunk. -- We can't use the mapgen seed as this would make the algorithm depending on the order the mapchunk generate. InitRandomizer(blockseed)