1
0
Fork 0

[mapgen] rebalance mapgen/init core code

mapgen
kay27 2021-04-28 03:03:47 +04:00
parent 29727136ac
commit c23bb1d59d
12 changed files with 316 additions and 326 deletions

View File

@ -1,12 +1,17 @@
mcl_mapgen = {}
mcl_mapgen.overworld = {}
mcl_mapgen.nether = {}
mcl_mapgen.end = {}
local minetest_log, math_floor = minetest.log, math.floor
local minetest_get_node = minetest.get_node
-- Calculate mapgen_edge_min/mapgen_edge_max
mcl_mapgen.CS = math.max(1, tonumber(minetest.get_mapgen_setting("chunksize")) or 5)
mcl_mapgen.BS = math.max(1, core.MAP_BLOCKSIZE or 16)
mcl_mapgen.LIMIT = math.max(1, tonumber(minetest.get_mapgen_setting("mapgen_limit")) or 31000)
mcl_mapgen.MAX_LIMIT = math.max(1, core.MAX_MAP_GENERATION_LIMIT or 31000)
mcl_mapgen.OFFSET = - math.floor(mcl_mapgen.CS / 2)
mcl_mapgen.OFFSET = - math_floor(mcl_mapgen.CS / 2)
mcl_mapgen.OFFSET_NODES = mcl_mapgen.OFFSET * mcl_mapgen.BS
mcl_mapgen.CS_NODES = mcl_mapgen.CS * mcl_mapgen.BS
@ -16,15 +21,17 @@ local central_chunk_max_pos = central_chunk_min_pos + mcl_mapgen.CS_NODES - 1
local ccfmin = central_chunk_min_pos - mcl_mapgen.BS -- Fullminp/fullmaxp of central chunk, in nodes
local ccfmax = central_chunk_max_pos + mcl_mapgen.BS
local mapgen_limit_b = math.floor(math.min(mcl_mapgen.LIMIT, mcl_mapgen.MAX_LIMIT) / mcl_mapgen.BS)
local mapgen_limit_b = math_floor(math.min(mcl_mapgen.LIMIT, mcl_mapgen.MAX_LIMIT) / mcl_mapgen.BS)
local mapgen_limit_min = - mapgen_limit_b * mcl_mapgen.BS
local mapgen_limit_max = (mapgen_limit_b + 1) * mcl_mapgen.BS - 1
local numcmin = math.max(math.floor((ccfmin - mapgen_limit_min) / mcl_vars.chunk_size_in_nodes), 0) -- Number of complete chunks from central chunk
local numcmax = math.max(math.floor((mapgen_limit_max - ccfmax) / mcl_vars.chunk_size_in_nodes), 0) -- fullminp/fullmaxp to effective mapgen limits.
local numcmin = math.max(math_floor((ccfmin - mapgen_limit_min) / mcl_mapgen.CS_NODES), 0) -- Number of complete chunks from central chunk
local numcmax = math.max(math_floor((mapgen_limit_max - ccfmax) / mcl_mapgen.CS_NODES), 0) -- fullminp/fullmaxp to effective mapgen limits.
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))
------------------------------------------
@ -33,12 +40,10 @@ local lvm, block, lvm_block, lvm_chunk, param2, nodes_block, nodes_chunk = 0, 0,
local lvm_buffer, lvm_param2_buffer = {}, {} -- Static buffer pointers
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 = math.floor(mcl_vars.central_chunk_offset_in_nodes / BS) -- Central mapchunk offset (in blocks)
local offset = mcl_mapgen.OFFSET -- Central mapchunk offset (in blocks)
local DEFAULT_PRIORITY = 5000
local minetest_log, math_floor = minetest.log, math.floor
function mcl_mapgen.register_chunk_generator(callback_function, priority)
nodes_chunk = nodes_chunk + 1
node_chunk_queue[nodes_chunk] = {i = priority or DEFAULT_PRIORITY, f = callback_function}
@ -141,15 +146,17 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
end
end
if lvm > 0 then
if vm_context.write then
vm:set_data(data)
end
if vm_context.write_param2 then
vm:set_param2_data(data2)
end
vm:calc_lighting(p1, p2, shadow)
vm:calc_lighting(minp, maxp, vm_context.shadow) -- TODO: check boundaries
vm:write_to_map()
vm:update_liquids()
end
for _, v in pairs(node_chunk_queue) do
v.f(minp, maxp, blockseed)
@ -174,11 +181,11 @@ function mcl_mapgen.get_far_node(p)
end
local function coordinate_to_block(x)
return math_floor(x / mcl_mapgen.BS)
return math_floor(x / BS)
end
local function coordinate_to_chunk(x)
return math_floor((coordinate_to_block(x) - central_chunk_offset) / mcl_mapgen.CS)
return math_floor((coordinate_to_block(x) - offset) / CS)
end
function mcl_mapgen.pos_to_block(pos)
@ -197,7 +204,7 @@ function mcl_mapgen.pos_to_chunk(pos)
}
end
local k_positive = math.ceil(mcl_mapgen.MAX_LIMIT / mcl_vars.chunk_size_in_nodes)
local k_positive = math.ceil(mcl_mapgen.MAX_LIMIT / mcl_mapgen.CS_NODES)
local k_positive_z = k_positive * 2
local k_positive_y = k_positive_z * k_positive_z
@ -210,17 +217,19 @@ function mcl_mapgen.get_chunk_number(pos) -- unsigned int
end
-- Mapgen variables
local mg_name = minetest.get_mapgen_setting("mg_name")
local minecraft_height_limit = 256
local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true"
local singlenode = mg_name == "singlenode"
mcl_mapgen.name = minetest.get_mapgen_setting("mg_name")
mcl_mapgen.superflat = mcl_mapgen.name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true"
mcl_mapgen.singlenode = mcl_mapgen.name == "singlenode"
mcl_mapgen.normal = not mcl_mapgen.superflat and not mcl_mapgen.singlenode
local superflat, singlenode, normal = mcl_mapgen.superflat, mcl_mapgen.singlenode, mcl_mapgen.normal
minetest_log("action", "[mcl_mapgen] Mapgen mode: " .. normal and "normal" or (superflat and "superflat" or "singlenode"))
mcl_mapgen.minecraft_height_limit = 256
mcl_mapgen.bedrock_is_rough = normal
if not superflat and not singlenode then
-- Normal mode
--[[ Realm stacking (h is for height)
- Overworld (h>=256)
- Void (h>=1000)
@ -232,74 +241,55 @@ if not superflat and not singlenode then
]]
-- Overworld
mcl_vars.mg_overworld_min = -62
mcl_vars.mg_overworld_max_official = mcl_vars.mg_overworld_min + minecraft_height_limit
mcl_vars.mg_bedrock_overworld_min = mcl_vars.mg_overworld_min
mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min + 4
mcl_vars.mg_lava_overworld_max = mcl_vars.mg_overworld_min + 10
mcl_vars.mg_lava = true
mcl_vars.mg_bedrock_is_rough = true
elseif singlenode then
mcl_vars.mg_overworld_min = -66
mcl_vars.mg_overworld_max_official = mcl_vars.mg_overworld_min + minecraft_height_limit
mcl_vars.mg_bedrock_overworld_min = mcl_vars.mg_overworld_min
mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min
mcl_vars.mg_lava = false
mcl_vars.mg_lava_overworld_max = mcl_vars.mg_overworld_min
mcl_vars.mg_bedrock_is_rough = false
else
-- Classic superflat
local ground = minetest.get_mapgen_setting("mgflat_ground_level")
ground = tonumber(ground)
if not ground then
ground = 8
end
mcl_vars.mg_overworld_min = ground - 3
mcl_vars.mg_overworld_max_official = mcl_vars.mg_overworld_min + minecraft_height_limit
mcl_vars.mg_bedrock_overworld_min = mcl_vars.mg_overworld_min
mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min
mcl_vars.mg_lava = false
mcl_vars.mg_lava_overworld_max = mcl_vars.mg_overworld_min
mcl_vars.mg_bedrock_is_rough = false
mcl_mapgen.overworld.min = -62
if superflat then
mcl_mapgen.ground = tonumber(minetest.get_mapgen_setting("mgflat_ground_level")) or 8
mcl_mapgen.overworld.min = ground - 3
end
-- if singlenode then mcl_mapgen.overworld.min = -66 end -- DONT KNOW WHY
mcl_mapgen.overworld.max = mcl_mapgen.EDGE_MAX
mcl_mapgen.overworld.bedrock_min = mcl_mapgen.overworld.min
mcl_mapgen.overworld.bedrock_max = mcl_mapgen.overworld.bedrock_min + (mcl_mapgen.bedrock_is_rough and 4 or 0)
mcl_mapgen.lava = normal
mcl_mapgen.lava_overworld_max = mcl_mapgen.overworld.min + (normal and 10 or 0)
mcl_vars.mg_overworld_max = mcl_mapgen.EDGE_MAX
-- The Nether (around Y = -29000)
mcl_vars.mg_nether_min = -29067 -- Carefully chosen to be at a mapchunk border
mcl_vars.mg_nether_max = mcl_vars.mg_nether_min + 128
mcl_vars.mg_bedrock_nether_bottom_min = mcl_vars.mg_nether_min
mcl_vars.mg_bedrock_nether_top_max = mcl_vars.mg_nether_max
mcl_mapgen.nether.min = -29067 -- Carefully chosen to be at a mapchunk border
mcl_mapgen.nether.max = mcl_mapgen.nether.min + 128
mcl_mapgen.nether.bedrock_bottom_min = mcl_mapgen.nether.min
mcl_mapgen.nether.bedrock_top_max = mcl_mapgen.nether.max
if not superflat then
mcl_vars.mg_bedrock_nether_bottom_max = mcl_vars.mg_bedrock_nether_bottom_min + 4
mcl_vars.mg_bedrock_nether_top_min = mcl_vars.mg_bedrock_nether_top_max - 4
mcl_vars.mg_lava_nether_max = mcl_vars.mg_nether_min + 31
mcl_mapgen.nether.bedrock_bottom_max = mcl_vars.mg_bedrock_nether_bottom_min + 4
mcl_mapgen.nether.bedrock_top_min = mcl_vars.mg_bedrock_nether_top_max - 4
mcl_mapgen.nether.lava_max = mcl_mapgen.nether.min + 31
else
-- Thin bedrock in classic superflat mapgen
mcl_vars.mg_bedrock_nether_bottom_max = mcl_vars.mg_bedrock_nether_bottom_min
mcl_vars.mg_bedrock_nether_top_min = mcl_vars.mg_bedrock_nether_top_max
mcl_vars.mg_lava_nether_max = mcl_vars.mg_nether_min + 2
mcl_mapgen.nether.bedrock_bottom_max = mcl_vars.mg_bedrock_nether_bottom_min
mcl_mapgen.nether.bedrock_top_min = mcl_vars.mg_bedrock_nether_top_max
mcl_mapgen.nether.lava_max = mcl_mapgen.nether.min + 2
end
if mg_name == "flat" then
if mcl_mapgen.name == "flat" then
if superflat then
mcl_vars.mg_flat_nether_floor = mcl_vars.mg_bedrock_nether_bottom_max + 4
mcl_vars.mg_flat_nether_ceiling = mcl_vars.mg_bedrock_nether_bottom_max + 52
mcl_mapgen.nether.flat_nether_floor = mcl_mapgen.nether.bedrock_nether_bottom_max + 4
mcl_mapgen.nether.flat_nether_ceiling = mcl_mapgen.nether.bedrock_nether_bottom_max + 52
else
mcl_vars.mg_flat_nether_floor = mcl_vars.mg_lava_nether_max + 4
mcl_vars.mg_flat_nether_ceiling = mcl_vars.mg_lava_nether_max + 52
mcl_mapgen.nether.flat_nether_floor = mcl_mapgen.nether.lava_nether_max + 4
mcl_mapgen.nether.flat_nether_ceiling = mcl_mapgen.nether.lava_nether_max + 52
end
end
-- The End (surface at ca. Y = -27000)
mcl_vars.mg_end_min = -27073 -- Carefully chosen to be at a mapchunk border
mcl_vars.mg_end_max_official = mcl_vars.mg_end_min + minecraft_height_limit
mcl_vars.mg_end_max = mcl_vars.mg_overworld_min - 2000
mcl_vars.mg_end_platform_pos = { x = 100, y = mcl_vars.mg_end_min + 74, z = 0 }
mcl_mapgen.end.min = -27073 -- Carefully chosen to be at a mapchunk border
mcl_mapgen.end.max_official = mcl_mapgen.end.min + mcl_mapgen.minecraft_height_limit
mcl_mapgen.end.max = mcl_mapgen.overworld.min - 2000
mcl_vars.mg_end_platform_pos = { x = 100, y = mcl_mapgen.end.min + 74, z = 0 }
-- Realm barrier used to safely separate the End from the void below the Overworld
mcl_vars.mg_realm_barrier_overworld_end_max = mcl_vars.mg_end_max
mcl_vars.mg_realm_barrier_overworld_end_min = mcl_vars.mg_end_max - 11
mcl_vars.mg_realm_barrier_overworld_end_max = mcl_mapgen.end.max
mcl_vars.mg_realm_barrier_overworld_end_min = mcl_mapgen.end.max - 11
-- Use MineClone 2-style dungeons
mcl_vars.mg_dungeons = true

View File

@ -3,25 +3,25 @@ mcl_worlds = {}
-- For a given position, returns a 2-tuple:
-- 1st return value: true if pos is in void
-- 2nd return value: true if it is in the deadly part of the void
local min1, min2, min3 = mcl_mapgen.overworld.min, mcl_mapgen.end.min, mcl_mapgen.nether.min
local max1, max2, max3 = mcl_mapgen.overworld.max, mcl_mapgen.end.max, mcl_mapgen.nether.max+128
function mcl_worlds.is_in_void(pos)
local void =
not ((pos.y < mcl_vars.mg_overworld_max and pos.y > mcl_vars.mg_overworld_min) or
(pos.y < mcl_vars.mg_nether_max+128 and pos.y > mcl_vars.mg_nether_min) or
(pos.y < mcl_vars.mg_end_max and pos.y > mcl_vars.mg_end_min))
local y = pos.y
local void = not ((y < max1 and y > min1) or (y < max2 and y > min2) or (y < max3 and y > min3))
local void_deadly = false
local deadly_tolerance = 64 -- the player must be this many nodes “deep” into the void to be damaged
if void then
-- Overworld → Void → End → Void → Nether → Void
if pos.y < mcl_vars.mg_overworld_min and pos.y > mcl_vars.mg_end_max then
void_deadly = pos.y < mcl_vars.mg_overworld_min - deadly_tolerance
elseif pos.y < mcl_vars.mg_end_min and pos.y > mcl_vars.mg_nether_max+128 then
if y < mcl_vars.min1 and y > max2 then
void_deadly = y < min1 - deadly_tolerance
elseif y < min2 and y > max3 then
-- The void between End and Nether. Like usual, but here, the void
-- *above* the Nether also has a small tolerance area, so player
-- can fly above the Nether without getting hurt instantly.
void_deadly = (pos.y < mcl_vars.mg_end_min - deadly_tolerance) and (pos.y > mcl_vars.mg_nether_max+128 + deadly_tolerance)
elseif pos.y < mcl_vars.mg_nether_min then
void_deadly = pos.y < mcl_vars.mg_nether_min - deadly_tolerance
void_deadly = (y < min2 - deadly_tolerance) and (y > max3 + deadly_tolerance)
elseif y < min3 then
void_deadly = y < min3 - deadly_tolerance
end
end
return void, void_deadly
@ -33,12 +33,12 @@ end
-- If the Y coordinate is not located in any dimension, it will return:
-- nil, "void"
function mcl_worlds.y_to_layer(y)
if y >= mcl_vars.mg_overworld_min then
return y - mcl_vars.mg_overworld_min, "overworld"
elseif y >= mcl_vars.mg_nether_min and y <= mcl_vars.mg_nether_max+128 then
return y - mcl_vars.mg_nether_min, "nether"
elseif y >= mcl_vars.mg_end_min and y <= mcl_vars.mg_end_max then
return y - mcl_vars.mg_end_min, "end"
if y >= min1 then
return y - min1, "overworld"
elseif y >= min3 and y <= max3 then
return y - min3, "nether"
elseif y >= min2 and y <= max2 then
return y - min2, "end"
else
return nil, "void"
end

View File

@ -233,15 +233,15 @@ mobs_mc.override.spawn_height = {
water = tonumber(minetest.settings:get("water_level")) or 0, -- Water level in the Overworld
-- Overworld boundaries (inclusive)
overworld_min = mcl_vars.mg_overworld_min,
overworld_max = mcl_vars.mg_overworld_max,
overworld_min = mcl_mapgen.overworld.min,
overworld_max = mcl_mapgen.overworld.max,
-- Nether boundaries (inclusive)
nether_min = mcl_vars.mg_nether_min,
nether_max = mcl_vars.mg_nether_max,
nether_min = mcl_mapgen.nether.min,
nether_max = mcl_mapgen.nether.max,
-- End boundaries (inclusive)
end_min = mcl_vars.mg_end_min,
end_max = mcl_vars.mg_end_max,
end_min = mcl_mapgen.end.min,
end_max = mcl_mapgen.end.max,
}

View File

@ -27,7 +27,7 @@ local DELAY = 3 -- seconds before teleporting in Nether portal in Survival mo
local DISTANCE_MAX = 128
local PORTAL = "mcl_portals:portal"
local OBSIDIAN = "mcl_core:obsidian"
local O_Y_MIN, O_Y_MAX = max(mcl_vars.mg_overworld_min, -31), min(mcl_vars.mg_overworld_max, 2048)
local O_Y_MIN, O_Y_MAX = max(mcl_mapgen.overworld.min, -31), min(mcl_mapgen.overworld.max, 2048)
local N_Y_MIN, N_Y_MAX = mcl_vars.mg_bedrock_nether_bottom_min, mcl_vars.mg_bedrock_nether_top_min - H_MIN
-- Alpha and particles
@ -66,7 +66,7 @@ minetest.register_on_shutdown(function()
storage:set_string("nether_exits_keys", minetest.serialize(keys))
end)
local get_node = mcl_vars.get_node
local get_node = mcl_mapgen.get_far_node
local set_node = minetest.set_node
local registered_nodes = minetest.registered_nodes
local is_protected = minetest.is_protected
@ -414,7 +414,7 @@ local function create_portal_2(pos1, name, obj)
end
local exit = build_nether_portal(pos1, W_MIN-2, H_MIN-2, orientation, name)
finalize_teleport(obj, exit)
local cn = mcl_vars.get_chunk_number(pos1)
local cn = mcl_mapgen.get_chunk_number(pos1)
chunks[cn] = nil
if queue[cn] then
for next_obj, _ in pairs(queue[cn]) do
@ -428,9 +428,9 @@ end
local function get_lava_level(pos, pos1, pos2)
if pos.y > -1000 then
return max(min(mcl_vars.mg_lava_overworld_max, pos2.y-1), pos1.y+1)
return max(min(mcl_mapgen.overworld.lava_max, pos2.y-1), pos1.y+1)
end
return max(min(mcl_vars.mg_lava_nether_max, pos2.y-1), pos1.y+1)
return max(min(mcl_mapgen.nether.lava_max, pos2.y-1), pos1.y+1)
end
local function ecb_scan_area_2(blockpos, action, calls_remaining, param)
@ -509,7 +509,7 @@ local function ecb_scan_area_2(blockpos, action, calls_remaining, param)
end
local function create_portal(pos, limit1, limit2, name, obj)
local cn = mcl_vars.get_chunk_number(pos)
local cn = mcl_mapgen.get_chunk_number(pos)
if chunks[cn] then
local q = queue[cn] or {}
q[obj] = true
@ -537,8 +537,8 @@ local function create_portal(pos, limit1, limit2, name, obj)
end
-- Basically the copy of code above, with minor additions to continue the search in single additional chunk below:
local next_chunk_1 = {x = pos1.x, y = pos1.y - mcl_vars.chunk_size_in_nodes, z = pos1.z}
local next_chunk_2 = add(next_chunk_1, mcl_vars.chunk_size_in_nodes - 1)
local next_chunk_1 = {x = pos1.x, y = pos1.y - mcl_mapgen.CS_NODES, z = pos1.z}
local next_chunk_2 = add(next_chunk_1, mcl_mapgen.CS_NODES - 1)
local next_pos = {x = pos.x, y=max(next_chunk_2.y, limit1.y), z = pos.z}
if limit1 and limit1.x and limit1.y and limit1.z then
pos1 = {x = max(min(limit1.x, pos.x), pos1.x), y = max(min(limit1.y, pos.y), pos1.y), z = max(min(limit1.z, pos.z), pos1.z)}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
name = mcl_biomes
author = maikerumine
description = Adds the various biomes and biome-related things for non-v6 map generators.
depends = mcl_init, mcl_mapgen_core, mcl_core, mcl_worlds, mcl_farming, mcl_flowers, mcl_end, mcl_ocean
depends = mcl_mapgen, mcl_mapgen_core, mcl_core, mcl_worlds, mcl_farming, mcl_flowers, mcl_end, mcl_ocean

View File

@ -32,11 +32,11 @@ local math_max = math.max
local math_ceil = math.ceil
--custom mcl_vars
local get_node = mcl_vars.get_node
local get_node = mcl_mapgen.get_far_node
local min_y = math_max(mcl_vars.mg_overworld_min, mcl_vars.mg_bedrock_overworld_max) + 1
local max_y = mcl_vars.mg_overworld_max - 1
local min_y = math_max(mcl_mapgen.overworld.min, mcl_vars.mg_bedrock_overworld_max) + 1
local max_y = mcl_mapgen.overworld.max - 1
-- Calculate the number of dungeon spawn attempts
-- In Minecraft, there 8 dungeon spawn attempts Minecraft chunk (16*256*16 = 65536 blocks).
-- Minetest chunks don't have this size, so scale the number accordingly.

View File

@ -97,8 +97,8 @@ for s=1, #specialstones do
clust_scarcity = 15*15*15,
clust_num_ores = 33,
clust_size = 5,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_vars.mg_overworld_max,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_mapgen.overworld.max,
noise_params = {
offset = 0,
scale = 1,
@ -117,8 +117,8 @@ for s=1, #specialstones do
clust_scarcity = 10*10*10,
clust_num_ores = 58,
clust_size = 7,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_vars.mg_overworld_max,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_mapgen.overworld.max,
noise_params = {
offset = 0,
scale = 1,
@ -142,8 +142,8 @@ minetest.register_ore({
clust_scarcity = 15*15*15,
clust_num_ores = 33,
clust_size = 4,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_vars.mg_overworld_max,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_mapgen.overworld.max,
noise_params = {
offset = 0,
scale = 1,
@ -164,7 +164,7 @@ minetest.register_ore({
clust_scarcity = 14*14*14,
clust_num_ores = 33,
clust_size = 5,
y_min = mcl_vars.mg_overworld_min,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_worlds.layer_to_y(111),
noise_params = {
offset = 0,
@ -191,7 +191,7 @@ if minetest.settings:get_bool("mcl_generate_ores", true) then
clust_scarcity = 525*3,
clust_num_ores = 5,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_worlds.layer_to_y(50),
})
minetest.register_ore({
@ -201,7 +201,7 @@ if minetest.settings:get_bool("mcl_generate_ores", true) then
clust_scarcity = 510*3,
clust_num_ores = 8,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_worlds.layer_to_y(50),
})
minetest.register_ore({
@ -211,7 +211,7 @@ if minetest.settings:get_bool("mcl_generate_ores", true) then
clust_scarcity = 500*3,
clust_num_ores = 12,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_worlds.layer_to_y(50),
})
@ -289,7 +289,7 @@ if minetest.settings:get_bool("mcl_generate_ores", true) then
clust_scarcity = 830,
clust_num_ores = 5,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_worlds.layer_to_y(39),
})
minetest.register_ore({
@ -315,7 +315,7 @@ if minetest.settings:get_bool("mcl_generate_ores", true) then
clust_scarcity = 4775,
clust_num_ores = 5,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_worlds.layer_to_y(30),
})
minetest.register_ore({
@ -325,7 +325,7 @@ if minetest.settings:get_bool("mcl_generate_ores", true) then
clust_scarcity = 6560,
clust_num_ores = 7,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_worlds.layer_to_y(30),
})
@ -353,7 +353,7 @@ if minetest.settings:get_bool("mcl_generate_ores", true) then
clust_scarcity = 10000,
clust_num_ores = 4,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_worlds.layer_to_y(12),
})
minetest.register_ore({
@ -363,7 +363,7 @@ if minetest.settings:get_bool("mcl_generate_ores", true) then
clust_scarcity = 5000,
clust_num_ores = 2,
clust_size = 2,
y_min = mcl_vars.mg_overworld_min,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_worlds.layer_to_y(12),
})
minetest.register_ore({
@ -373,7 +373,7 @@ if minetest.settings:get_bool("mcl_generate_ores", true) then
clust_scarcity = 10000,
clust_num_ores = 8,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_worlds.layer_to_y(12),
})
@ -411,7 +411,7 @@ if minetest.settings:get_bool("mcl_generate_ores", true) then
clust_scarcity = 500,
clust_num_ores = 4,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_worlds.layer_to_y(13),
})
minetest.register_ore({
@ -421,7 +421,7 @@ if minetest.settings:get_bool("mcl_generate_ores", true) then
clust_scarcity = 800,
clust_num_ores = 7,
clust_size = 4,
y_min = mcl_vars.mg_overworld_min,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_worlds.layer_to_y(13),
})
@ -462,7 +462,7 @@ if minetest.settings:get_bool("mcl_generate_ores", true) then
clust_scarcity = 14340,
clust_num_ores = 1,
clust_size = 1,
y_min = mcl_vars.mg_overworld_min,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_worlds.layer_to_y(29),
})
-- Rare spawn
@ -678,7 +678,7 @@ local function register_mgv6_decorations()
persist = 0.6
},
y_min = 4,
y_max = mcl_vars.mg_overworld_max,
y_max = mcl_mapgen.overworld.max,
decoration = "mcl_core:cactus",
height = 1,
height_max = 3,
@ -698,7 +698,7 @@ local function register_mgv6_decorations()
persist = 0.7
},
y_min = 1,
y_max = mcl_vars.mg_overworld_max,
y_max = mcl_mapgen.overworld.max,
decoration = "mcl_core:reeds",
height = 1,
height_max = 3,
@ -728,7 +728,7 @@ local function register_mgv6_decorations()
persist = 0.0,
},
y_min = 1,
y_max = mcl_vars.mg_overworld_max,
y_max = mcl_mapgen.overworld.max,
})
-- Large ferns
@ -757,7 +757,7 @@ local function register_mgv6_decorations()
persist = 0.66,
},
y_min = 1,
y_max = mcl_vars.mg_overworld_max,
y_max = mcl_mapgen.overworld.max,
})
-- Large flowers
@ -1006,7 +1006,7 @@ local function register_mgv6_decorations()
persist = 0.666
},
flags = "force_placement",
y_min = mcl_vars.mg_lava_overworld_max + 5,
y_min = mcl_mapgen.overworld.lava_max + 5,
y_max = -20,
})
@ -1038,7 +1038,7 @@ local function register_mgv6_decorations()
persist = 0.6
},
y_min = 1,
y_max = mcl_vars.mg_overworld_max,
y_max = mcl_mapgen.overworld.max,
decoration = mushrooms[m],
spawn_by = { "mcl_core:tree", "mcl_core:sprucetree", "mcl_core:darktree", "mcl_core:birchtree", },
num_spawn_by = 1,
@ -1059,7 +1059,7 @@ local function register_mgv6_decorations()
persist = 0.6
},
y_min = 4,
y_max = mcl_vars.mg_overworld_max,
y_max = mcl_mapgen.overworld.max,
decoration = "mcl_core:deadbush",
})
@ -1068,7 +1068,7 @@ local function register_mgv6_decorations()
offset = 0
end
if y_max == nil then
y_max = mcl_vars.mg_overworld_max
y_max = mcl_mapgen.overworld.max
end
minetest.register_decoration({
deco_type = "simple",
@ -1111,7 +1111,7 @@ local function register_mgv6_decorations()
sidelen = 16,
fill_ratio = 11.0, -- complete coverage
y_min = 1,
y_max = mcl_vars.mg_overworld_max,
y_max = mcl_mapgen.overworld.max,
decoration = "mcl_core:snow",
})
@ -1719,7 +1719,7 @@ local generate_underground_mushrooms = function(minp, maxp, seed)
local pr_shroom = PseudoRandom(seed-24359)
-- Generate rare underground mushrooms
-- TODO: Make them appear in groups, use Perlin noise
local min, max = mcl_vars.mg_lava_overworld_max + 4, 0
local min, max = mcl_mapgen.overworld.lava_max + 4, 0
if minp.y > max or maxp.y < min then
return
end
@ -1752,7 +1752,7 @@ end
local generate_nether_decorations = function(minp, maxp, seed)
local pr_nether = PseudoRandom(seed+667)
if minp.y > mcl_vars.mg_nether_max or maxp.y < mcl_vars.mg_nether_min then
if minp.y > mcl_mapgen.nether.max or maxp.y < mcl_mapgen.nether.min then
return
end
@ -1899,23 +1899,23 @@ local function basic(c)
local pr = PseudoRandom(blockseed)
-- The Void below the Nether:
lvm_used = set_layers(data, area, c_void , nil, mcl_mapgen.EDGE_MIN , mcl_vars.mg_nether_min -1, minp, maxp, lvm_used, pr)
lvm_used = set_layers(data, area, c_void , nil, mcl_mapgen.EDGE_MIN , mcl_mapgen.nether.min -1, minp, maxp, lvm_used, pr)
-- [[ THE NETHER: mcl_vars.mg_nether_min mcl_vars.mg_nether_max ]]
-- [[ THE NETHER: mcl_mapgen.nether.min mcl_mapgen.nether.max ]]
-- The Air on the Nether roof, https://git.minetest.land/MineClone2/MineClone2/issues/1186
lvm_used = set_layers(data, area, c_air , nil, mcl_vars.mg_nether_max +1, mcl_vars.mg_nether_max + 128 , minp, maxp, lvm_used, pr)
lvm_used = set_layers(data, area, c_air , nil, mcl_mapgen.nether.max +1, mcl_mapgen.nether.max + 128 , minp, maxp, lvm_used, pr)
-- The Void above the Nether below the End:
lvm_used = set_layers(data, area, c_void , nil, mcl_vars.mg_nether_max + 128 +1, mcl_vars.mg_end_min -1, minp, maxp, lvm_used, pr)
lvm_used = set_layers(data, area, c_void , nil, mcl_mapgen.nether.max + 128 +1, mcl_mapgen.end.min -1, minp, maxp, lvm_used, pr)
-- [[ THE END: mcl_vars.mg_end_min mcl_vars.mg_end_max ]]
-- [[ 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_vars.mg_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_vars.mg_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)
-- 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_vars.mg_overworld_min -1, minp, maxp, lvm_used, pr)
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)
if mg_name ~= "singlenode" then
@ -1931,8 +1931,8 @@ local function basic(c)
-- Big lava seas by replacing air below a certain height
if mcl_vars.mg_lava then
lvm_used = set_layers(data, area, c_lava, c_air, mcl_vars.mg_overworld_min, mcl_vars.mg_lava_overworld_max, minp, maxp, lvm_used, pr)
lvm_used = set_layers(data, area, c_nether_lava, c_air, mcl_vars.mg_nether_min, mcl_vars.mg_lava_nether_max, minp, maxp, lvm_used, pr)
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)
end
-- Clay, vines, cocoas
@ -1948,7 +1948,7 @@ local function basic(c)
-- Snow and sand fixes. This code implements snow consistency
-- and fixes floating sand and cut plants.
-- A snowy grass block must be below a top snow or snow block at all times.
if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then
if minp.y <= mcl_mapgen.overworld.max and maxp.y >= mcl_mapgen.overworld.min then
-- v6 mapgen:
if mg_name == "v6" then
@ -2014,7 +2014,7 @@ local function basic(c)
-- Nether block fixes:
-- * Replace water with Nether lava.
-- * Replace stone, sand dirt in v6 so the Nether works in v6.
elseif emin.y <= mcl_vars.mg_nether_max and emax.y >= mcl_vars.mg_nether_min then
elseif emin.y <= mcl_mapgen.nether.max and emax.y >= mcl_mapgen.nether.min then
if mg_name == "v6" then
local nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"})
for n=1, #nodes do
@ -2041,7 +2041,7 @@ local function basic(c)
-- * Replace water with end stone or air (depending on height).
-- * Remove stone, sand, dirt in v6 so our End map generator works in v6.
-- * Generate spawn platform (End portal destination)
elseif minp.y <= mcl_vars.mg_end_max and maxp.y >= mcl_vars.mg_end_min then
elseif minp.y <= mcl_mapgen.end.max and maxp.y >= mcl_mapgen.end.min then
local nodes
if mg_name == "v6" then
nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"})
@ -2083,11 +2083,11 @@ local function basic(c)
-- Final hackery: Set sun light level in the End.
-- -26912 is at a mapchunk border.
local shadow = true
if minp.y >= -26912 and maxp.y <= mcl_vars.mg_end_max then
if minp.y >= -26912 and maxp.y <= mcl_mapgen.end.max then
vm:set_lighting({day=15, night=15})
lvm_used = true
end
if minp.y >= mcl_vars.mg_end_min and maxp.y <= -26911 then
if minp.y >= mcl_mapgen.end.min and maxp.y <= -26911 then
shadow = false
lvm_used = true
end

View File

@ -110,14 +110,14 @@ mcl_structures.generate_igloo = function(pos, rotation, pr)
if r == 1 then
-- Select basement depth
local dim = mcl_worlds.pos_to_dimension(pos)
--local buffer = pos.y - (mcl_vars.mg_lava_overworld_max + 10)
--local buffer = pos.y - (mcl_mapgen.overworld.lava_max + 10)
local buffer
if dim == "nether" then
buffer = pos.y - (mcl_vars.mg_lava_nether_max + 10)
elseif dim == "end" then
buffer = pos.y - (mcl_vars.mg_end_min + 1)
elseif dim == "overworld" then
buffer = pos.y - (mcl_vars.mg_lava_overworld_max + 10)
buffer = pos.y - (mcl_mapgen.overworld.lava_max + 10)
else
return success
end
@ -277,7 +277,7 @@ local function hut_placement_callback(p1, p2, size, orientation, pr)
if not p1 or not p2 then return end
local legs = minetest.find_nodes_in_area(p1, p2, "mcl_core:tree")
for i = 1, #legs do
while minetest.get_item_group(mcl_vars.get_node({x=legs[i].x, y=legs[i].y-1, z=legs[i].z}, true, 333333).name, "water") ~= 0 do
while minetest.get_item_group(mcl_mapgen.get_far_node({x=legs[i].x, y=legs[i].y-1, z=legs[i].z}, true, 333333).name, "water") ~= 0 do
legs[i].y = legs[i].y - 1
minetest.swap_node(legs[i], {name = "mcl_core:tree", param2 = 2})
end

View File

@ -88,7 +88,7 @@ function settlements.create_site_plan(maxp, minp, pr)
-- find center_surface of chunk
local center_surface , surface_material = settlements.find_surface(center, true)
local chunks = {}
chunks[mcl_vars.get_chunk_number(center)] = true
chunks[mcl_mapgen.get_chunk_number(center)] = true
-- go build settlement around center
if not center_surface then return false end
@ -124,7 +124,7 @@ function settlements.create_site_plan(maxp, minp, pr)
ptx = settlements.round(ptx, 0)
ptz = settlements.round(ptz, 0)
local pos1 = { x=ptx, y=center_surface.y+50, z=ptz}
local chunk_number = mcl_vars.get_chunk_number(pos1)
local chunk_number = mcl_mapgen.get_chunk_number(pos1)
local pos_surface, surface_material
if chunks[chunk_number] then
pos_surface, surface_material = settlements.find_surface(pos1)

View File

@ -1,4 +1,4 @@
local get_node = mcl_vars.get_node
local get_node = mcl_mapgen.get_far_node
-------------------------------------------------------------------------------
-- function to copy tables

View File

@ -94,7 +94,7 @@ end
-- Max. and min. heights between rail corridors are generated
local height_min
if mcl_vars.mg_lava then
height_min = mcl_vars.mg_lava_overworld_max + 2
height_min = mcl_mapgen.overworld.lava_max + 2
else
height_min = mcl_vars.mg_bedrock_overworld_max + 2
end