1
0
Fork 0

some refactoring

This commit is contained in:
cora 2022-09-10 04:39:49 +02:00 committed by Gitea
parent 8c2a1017c6
commit 52c4a7dc28
5 changed files with 112 additions and 439 deletions

View File

@ -3538,6 +3538,18 @@ local function register_decorations()
rotation = "0", rotation = "0",
}) })
--Snow on snowy dirt
minetest.register_decoration({
deco_type = "simple",
place_on = {"mcl_core:dirt_with_grass_snow"},
sidelen = 80,
fill_ratio = 10,
flags = "all_floors",
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_vars.mg_overworld_max,
decoration = "mcl_core:snow",
})
--Mushrooms in caves --Mushrooms in caves
minetest.register_decoration({ minetest.register_decoration({
deco_type = "simple", deco_type = "simple",

View File

@ -55,8 +55,6 @@ minetest.register_alias("mapgen_stair_desert_stone", "mcl_stairs:stair_sandstone
local mg_name = minetest.get_mapgen_setting("mg_name") local mg_name = minetest.get_mapgen_setting("mg_name")
local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true" local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true"
local WITCH_HUT_HEIGHT = 3 -- Exact Y level to spawn witch huts at. This height refers to the height of the floor
-- End exit portal position -- End exit portal position
local END_EXIT_PORTAL_POS = vector.new(-3, -27003, -3) local END_EXIT_PORTAL_POS = vector.new(-3, -27003, -3)
@ -614,6 +612,26 @@ local function set_layers(data, area, content_id, check, min, max, minp, maxp, l
return lvm_used return lvm_used
end end
local function set_palette(minp,maxp,data2,area,biomemap,nodes)
-- Flat area at y=0 to read biome 3 times faster than 5.3.0.get_biome_data(pos).biome: 43us vs 125us per iteration:
local aream = VoxelArea:new({MinEdge={x=minp.x, y=0, z=minp.z}, MaxEdge={x=maxp.x, y=0, z=maxp.z}})
local nodes = minetest.find_nodes_in_area(minp, maxp, nodes)
for n=1, #nodes do
local n = nodes[n]
local p_pos = area:index(n.x, n.y, n.z)
local b_pos = aream:index(n.x, 0, n.z)
local bn = minetest.get_biome_name(biomemap[b_pos])
if bn then
local biome = minetest.registered_biomes[bn]
if biome and biome._mcl_biome_type then
data2[p_pos] = biome._mcl_palette_index
lvm_used = true
end
end
end
return lvm_used
end
-- Below the bedrock, generate air/void -- Below the bedrock, generate air/void
local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed)
local biomemap --ymin, ymax local biomemap --ymin, ymax
@ -656,134 +674,79 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed)
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_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_nether_lava, c_air, mcl_vars.mg_nether_min, mcl_vars.mg_lava_nether_max, minp, maxp, lvm_used, pr)
end end
end
-- Clay, vines, cocoas return lvm_used, false
lvm_used = generate_clay(minp, maxp, blockseed, data, area, lvm_used) end
biomemap = minetest.get_mapgen_object("biomemap") local function block_fixes(vm, data, data2, emin, emax, area, minp, maxp, blockseed)
lvm_used = generate_tree_decorations(minp, maxp, blockseed, data, data2, area, biomemap, lvm_used, pr) local biomemap = minetest.get_mapgen_object("biomemap")
local lvm_used = false
local pr = PseudoRandom(blockseed)
if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then
-- Set param2 (=color) of sugar cane and grass
lvm_used = set_palette(minp,maxp,data2,area,biomemap,{"mcl_core:reeds","mcl_core:dirt_with_grass"})
end
return lvm_used
end
----- Interactive block fixing section -----
----- The section to perform basic block overrides of the core mapgen generated world. -----
-- Snow and sand fixes. This code implements snow consistency -- End block fixes:
-- and fixes floating sand and cut plants. -- * Replace water with end stone or air (depending on height).
-- A snowy grass block must be below a top snow or snow block at all times. -- * Remove stone, sand, dirt in v6 so our End map generator works in v6.
if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then -- * Generate spawn platform (End portal destination)
-- v6 mapgen: local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed)
if mg_name ~= "v6" then if minp.y < -26912 or maxp.y >= mcl_vars.mg_end_max then return end
-- Non-v6 mapgens: local biomemap --ymin, ymax
-- Set param2 (=color) of grass blocks. local lvm_used = false
-- Clear snowy grass blocks without snow above to ensure consistency. local pr = PseudoRandom(blockseed)
local nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:dirt_with_grass", "mcl_core:dirt_with_grass_snow"}) local nodes
if mg_name ~= "v6" then
-- Flat area at y=0 to read biome 3 times faster than 5.3.0.get_biome_data(pos).biome: 43us vs 125us per iteration: nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source"})
local aream = VoxelArea:new({MinEdge={x=minp.x, y=0, z=minp.z}, MaxEdge={x=maxp.x, y=0, z=maxp.z}}) if #nodes > 0 then
for n=1, #nodes do lvm_used = true
local n = nodes[n] for _,n in pairs(nodes) do
local p_pos = area:index(n.x, n.y, n.z) data[area:index(n.x, n.y, n.z)] = c_air
local p_pos_above = area:index(n.x, n.y+1, n.z)
--local p_pos_below = area:index(n.x, n.y-1, n.z)
local b_pos = aream:index(n.x, 0, n.z)
local bn = minetest.get_biome_name(biomemap[b_pos])
if bn then
local biome = minetest.registered_biomes[bn]
if biome and biome._mcl_biome_type then
data2[p_pos] = biome._mcl_palette_index
lvm_used = true
end
end
if data[p_pos] == c_dirt_with_grass_snow and p_pos_above and data[p_pos_above] ~= c_top_snow and data[p_pos_above] ~= c_snow_block then
data[p_pos] = c_dirt_with_grass
lvm_used = true
end
end
-- Set param2 (=color) of sugar cane
nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:reeds"})
for n=1, #nodes do
local n = nodes[n]
local p_pos = area:index(n.x, n.y, n.z)
local b_pos = aream:index(n.x, 0, n.z)
local bn = minetest.get_biome_name(biomemap[b_pos])
if bn then
local biome = minetest.registered_biomes[bn]
if biome and biome._mcl_biome_type then
data2[p_pos] = biome._mcl_palette_index
lvm_used = true
end
end
end
end
-- 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
if mg_name ~= "v6" then
local nodes = minetest.find_nodes_in_area(emin, emax, {"group:water"})
for _, n in pairs(nodes) do
data[area:index(n.x, n.y, n.z)] = c_nether_lava
end
end
-- End block fixes:
-- * 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
local nodes
if mg_name ~= "v6" then
nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source"})
if #nodes > 0 then
lvm_used = true
for _,n in pairs(nodes) do
data[area:index(n.x, n.y, n.z)] = c_air
end
end
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
--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)}
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
local p_pos = area:index(x, y, z)
if y == mcl_vars.mg_end_platform_pos.y then
data[p_pos] = c_obsidian
else
data[p_pos] = c_air
end
end
end
end
lvm_used = true
end end
end end
end end
-- Final hackery: Set sun light level in the End. -- Obsidian spawn platform
-- -26912 is at a mapchunk border. if minp.y <= mcl_vars.mg_end_platform_pos.y and maxp.y >= mcl_vars.mg_end_platform_pos.y and
local shadow = true minp.x <= mcl_vars.mg_end_platform_pos.x and maxp.x >= mcl_vars.mg_end_platform_pos.z and
if minp.y >= -26912 and maxp.y <= mcl_vars.mg_end_max then minp.z <= mcl_vars.mg_end_platform_pos.z and maxp.z >= mcl_vars.mg_end_platform_pos.z then
vm:set_lighting({day=15, night=15})
--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)}
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
local p_pos = area:index(x, y, z)
if y == mcl_vars.mg_end_platform_pos.y then
data[p_pos] = c_obsidian
else
data[p_pos] = c_air
end
end
end
end
lvm_used = true lvm_used = true
end end
if minp.y >= mcl_vars.mg_end_min and maxp.y <= -26911 then -- Final hackery: Set sun light level in the End.
-- -26912 is at a mapchunk border.
vm:set_lighting({day=15, night=15})
lvm_used = true
local shadow = true
if emin.y >= mcl_vars.mg_end_min and emax.y <= -26911 then
shadow = false shadow = false
lvm_used = true lvm_used = true
end end
return lvm_used, shadow return lvm_used, shadow
end end
mcl_mapgen_core.register_generator("main", basic, basic_node, 1, true)
mcl_mapgen_core.register_generator("end_exit_portal",nil, function(minp, maxp, blockseed) local function end_node(minp, maxp, blockseed)
if minp.y <= END_EXIT_PORTAL_POS.y and maxp.y >= END_EXIT_PORTAL_POS.y and if minp.y <= END_EXIT_PORTAL_POS.y and maxp.y >= END_EXIT_PORTAL_POS.y and
minp.x <= END_EXIT_PORTAL_POS.x and maxp.x >= END_EXIT_PORTAL_POS.x and minp.x <= END_EXIT_PORTAL_POS.x and maxp.x >= END_EXIT_PORTAL_POS.x and
minp.z <= END_EXIT_PORTAL_POS.z and maxp.z >= END_EXIT_PORTAL_POS.z then minp.z <= END_EXIT_PORTAL_POS.z and maxp.z >= END_EXIT_PORTAL_POS.z then
@ -796,7 +759,11 @@ mcl_mapgen_core.register_generator("end_exit_portal",nil, function(minp, maxp, b
end end
generate_end_exit_portal(END_EXIT_PORTAL_POS) generate_end_exit_portal(END_EXIT_PORTAL_POS)
end end
end,101,true) end
mcl_mapgen_core.register_generator("main", basic, nil, 1, true)
mcl_mapgen_core.register_generator("end_fixes", end_basic, end_node, 20, true)
mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blockseed) mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blockseed)
local gennotify = minetest.get_mapgen_object("gennotify") local gennotify = minetest.get_mapgen_object("gennotify")

View File

@ -4,6 +4,9 @@ local deepslate_min = mcl_vars.mg_overworld_min
local copper_mod = minetest.get_modpath("mcl_copper") local copper_mod = minetest.get_modpath("mcl_copper")
local mg_name = minetest.get_mapgen_setting("mg_name")
local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true"
local mountains = { local mountains = {
"ExtremeHills", "ExtremeHills_beach", "ExtremeHills_ocean", "ExtremeHills_deep_ocean", "ExtremeHills_underground", "ExtremeHills", "ExtremeHills_beach", "ExtremeHills_ocean", "ExtremeHills_deep_ocean", "ExtremeHills_underground",
"ExtremeHills+", "ExtremeHills+_ocean", "ExtremeHills+_deep_ocean", "ExtremeHills+_underground", "ExtremeHills+", "ExtremeHills+_ocean", "ExtremeHills+_deep_ocean", "ExtremeHills+_underground",
@ -13,7 +16,7 @@ local mountains = {
--Clay --Clay
minetest.register_ore({ minetest.register_ore({
ore_type = "blob", ore_type = "blob",
ore = node, ore = "mcl_core:clay",
wherein = {"mcl_core:sand","mcl_core:stone","mcl_core:gravel"}, wherein = {"mcl_core:sand","mcl_core:stone","mcl_core:gravel"},
clust_scarcity = 15*15*15, clust_scarcity = 15*15*15,
clust_num_ores = 33, clust_num_ores = 33,
@ -24,7 +27,7 @@ minetest.register_ore({
offset = 0, offset = 0,
scale = 1, scale = 1,
spread = {x=250, y=250, z=250}, spread = {x=250, y=250, z=250},
seed = 3245123, seed = 34843,
octaves = 3, octaves = 3,
persist = 0.6, persist = 0.6,
lacunarity = 2, lacunarity = 2,

View File

@ -1,3 +1,5 @@
local WITCH_HUT_HEIGHT = 3 -- Exact Y level to spawn witch huts at. This height refers to the height of the floor
local function register_mgv6_decorations() local function register_mgv6_decorations()
-- Cacti -- Cacti
minetest.register_decoration({ minetest.register_decoration({
@ -773,11 +775,19 @@ local function remove_mgv6_broken_plants(minp,maxp)
end end
end end
local function nether_fixes(minp,maxp) local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed)
if not (minp.y <= mcl_vars.mg_nether_max and maxp.y >= mcl_vars.mg_nether_min) then if not (minp.y <= mcl_vars.mg_nether_max and maxp.y >= mcl_vars.mg_nether_min) then
return return
end end
local nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"}) -- Nether block fixes:
-- * Replace water with Nether lava.
-- * Replace stone, sand dirt in v6 so the Nether works in v6.
local nodes = minetest.find_nodes_in_area(emin, emax, {"group:water"})
for _, n in pairs(nodes) do
data[area:index(n.x, n.y, n.z)] = c_nether_lava
lvm_used = true
end
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 for n=1, #nodes do
local p_pos = area:index(nodes[n].x, nodes[n].y, nodes[n].z) local p_pos = area:index(nodes[n].x, nodes[n].y, nodes[n].z)
if data[p_pos] == c_water then if data[p_pos] == c_water then
@ -812,7 +822,6 @@ local function basic_node(minp, maxp, blockseed)
if mg_name == "v6" then if mg_name == "v6" then
generate_underground_mushrooms(minp, maxp, blockseed) generate_underground_mushrooms(minp, maxp, blockseed)
generate_nether_decorations(minp, maxp, blockseed) generate_nether_decorations(minp, maxp, blockseed)
nether_fixes(minp,maxp)
end_fixes(minp,maxp) end_fixes(minp,maxp)
remove_mgv6_broken_plants(minp,maxp,blockseed) remove_mgv6_broken_plants(minp,maxp,blockseed)
generate_mgv6_structures(minp, maxp, blockseed, minetest.get_mapgen_object("biomemap")) generate_mgv6_structures(minp, maxp, blockseed, minetest.get_mapgen_object("biomemap"))
@ -820,4 +829,4 @@ local function basic_node(minp, maxp, blockseed)
end end
end end
mcl_mapgen_core.register_generator("mgv6-fixes", nil, basic_node, 2, true) mcl_mapgen_core.register_generator("mgv6-fixes", basic, basic_node, 10, true)

View File

@ -1,318 +0,0 @@
-- End exit portal position
local END_EXIT_PORTAL_POS = vector.new(-3, -27003, -3)
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
-- Disable builtin dungeons, we provide our own dungeons
mg_flags.dungeons = false
if superflat then
-- Enforce superflat-like mapgen: no caves, decor, lakes and hills
mg_flags.caves = false
mg_flags.decorations = false
minetest.set_mapgen_setting("mgflat_spflags", "nolakes,nohills", true)
end
local mg_flags_str = ""
for k,v in pairs(mg_flags) do
if v == false then
k = "no" .. k
end
mg_flags_str = mg_flags_str .. k .. ","
end
if string.len(mg_flags_str) > 0 then
mg_flags_str = string.sub(mg_flags_str, 1, string.len(mg_flags_str)-1)
end
minetest.set_mapgen_setting("mg_flags", mg_flags_str, true)
-- Takes an index of a biomemap table (from minetest.get_mapgen_object),
-- minp and maxp (from an on_generated callback) and returns the real world coordinates
-- as X, Z.
-- Inverse function of xz_to_biomemap
--[[local function biomemap_to_xz(index, minp, maxp)
local xwidth = maxp.x - minp.x + 1
local zwidth = maxp.z - minp.z + 1
local x = ((index-1) % xwidth) + minp.x
local z = ((index-1) / zwidth) + minp.z
return x, z
end]]
-- Takes x and z coordinates and minp and maxp of a generated chunk
-- (in on_generated callback) and returns a biomemap index)
-- Inverse function of biomemap_to_xz
local function xz_to_biomemap_index(x, z, minp, maxp)
local xwidth = maxp.x - minp.x + 1
local zwidth = maxp.z - minp.z + 1
local minix = x % xwidth
local miniz = z % zwidth
return (minix + miniz * zwidth) + 1
end
local function generate_end_exit_portal(pos)
local obj = minetest.add_entity(vector.add(pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon")
if obj then
local dragon_entity = obj:get_luaentity()
dragon_entity._initial = true
dragon_entity._portal_pos = pos
else
minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn")
end
mcl_structures.call_struct(pos, "end_exit_portal")
end
-- Helper function to set all nodes in the layers between min and max.
-- content_id: Node to set
-- check: optional.
-- If content_id, node will be set only if it is equal to check.
-- If function(pos_to_check, content_id_at_this_pos), will set node only if returns true.
-- min, max: Minimum and maximum Y levels of the layers to set
-- minp, maxp: minp, maxp of the on_generated
-- lvm_used: Set to true if any node in this on_generated has been set before.
--
-- returns true if any node was set and lvm_used otherwise
local function set_layers(data, area, content_id, check, min, max, minp, maxp, lvm_used, pr)
if (maxp.y >= min and minp.y <= max) then
for y = math.max(min, minp.y), math.min(max, maxp.y) do
for x = minp.x, maxp.x do
for z = minp.z, maxp.z do
local p_pos = area:index(x, y, z)
if check then
if type(check) == "function" and check({x=x,y=y,z=z}, data[p_pos], pr) then
data[p_pos] = content_id
lvm_used = true
elseif check == data[p_pos] then
data[p_pos] = content_id
lvm_used = true
end
else
data[p_pos] = content_id
lvm_used = true
end
end
end
end
end
return lvm_used
end
-- Generate basic layer-based nodes: void, bedrock, realm barrier, lava seas, etc.
-- Also perform some basic node replacements.
local bedrock_check
if mcl_vars.mg_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 top
if diff == 0 or ndiff1 == 0 or ndiff2 == 4 then
-- 50% bedrock chance
top = 2
elseif diff == 1 or ndiff1 == 1 or ndiff2 == 3 then
-- 66.666...%
top = 3
elseif diff == 2 or ndiff1 == 2 or ndiff2 == 2 then
-- 75%
top = 4
elseif diff == 3 or ndiff1 == 3 or ndiff2 == 1 then
-- 90%
top = 10
elseif diff == 4 or ndiff1 == 4 or ndiff2 == 0 then
-- 100%
return true
else
-- Not in bedrock layer
return false
end
return pr:next(1, top) <= top-1
end
end
-- Below the bedrock, generate air/void
local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed)
local biomemap --ymin, ymax
local lvm_used = false
local pr = PseudoRandom(blockseed)
-- The Void below the Nether:
lvm_used = set_layers(data, area, c_void , nil, mcl_vars.mapgen_edge_min , mcl_vars.mg_nether_min -1, minp, maxp, lvm_used, pr)
-- [[ THE NETHER: mcl_vars.mg_nether_min mcl_vars.mg_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)
-- 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)
-- [[ THE END: mcl_vars.mg_end_min mcl_vars.mg_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)
-- 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)
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)
-- 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)
end
-- 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)
end
----- Interactive block fixing section -----
----- The section to perform basic block overrides of the core mapgen generated world. -----
-- 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
-- v6 mapgen:
if mg_name ~= "v6" then
-- Non-v6 mapgens:
-- Set param2 (=color) of grass blocks.
-- Clear snowy grass blocks without snow above to ensure consistency.
local nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:dirt_with_grass", "mcl_core:dirt_with_grass_snow"})
-- Flat area at y=0 to read biome 3 times faster than 5.3.0.get_biome_data(pos).biome: 43us vs 125us per iteration:
local aream = VoxelArea:new({MinEdge={x=minp.x, y=0, z=minp.z}, MaxEdge={x=maxp.x, y=0, z=maxp.z}})
for n=1, #nodes do
local n = nodes[n]
local p_pos = area:index(n.x, n.y, n.z)
local p_pos_above = area:index(n.x, n.y+1, n.z)
--local p_pos_below = area:index(n.x, n.y-1, n.z)
local b_pos = aream:index(n.x, 0, n.z)
local bn = minetest.get_biome_name(biomemap[b_pos])
if bn then
local biome = minetest.registered_biomes[bn]
if biome and biome._mcl_biome_type then
data2[p_pos] = biome._mcl_palette_index
lvm_used = true
end
end
if data[p_pos] == c_dirt_with_grass_snow and p_pos_above and data[p_pos_above] ~= c_top_snow and data[p_pos_above] ~= c_snow_block then
data[p_pos] = c_dirt_with_grass
lvm_used = true
end
end
-- Set param2 (=color) of sugar cane
nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:reeds"})
for n=1, #nodes do
local n = nodes[n]
local p_pos = area:index(n.x, n.y, n.z)
local b_pos = aream:index(n.x, 0, n.z)
local bn = minetest.get_biome_name(biomemap[b_pos])
if bn then
local biome = minetest.registered_biomes[bn]
if biome and biome._mcl_biome_type then
data2[p_pos] = biome._mcl_palette_index
lvm_used = true
end
end
end
end
-- 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
if mg_name ~= "v6" then
local nodes = minetest.find_nodes_in_area(emin, emax, {"group:water"})
for _, n in pairs(nodes) do
data[area:index(n.x, n.y, n.z)] = c_nether_lava
end
end
-- End block fixes:
-- * 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
local nodes
if mg_name ~= "v6" then
nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source"})
if #nodes > 0 then
lvm_used = true
for _,n in pairs(nodes) do
data[area:index(n.x, n.y, n.z)] = c_air
end
end
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
--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)}
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
local p_pos = area:index(x, y, z)
if y == mcl_vars.mg_end_platform_pos.y then
data[p_pos] = c_obsidian
else
data[p_pos] = c_air
end
end
end
end
lvm_used = true
end
end
end
-- 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
vm:set_lighting({day=15, night=15})
lvm_used = true
end
if minp.y >= mcl_vars.mg_end_min and maxp.y <= -26911 then
shadow = false
lvm_used = true
end
return lvm_used, shadow
end
mcl_mapgen_core.register_generator("main", basic, basic_node, 1, true)
mcl_mapgen_core.register_generator("end_exit_portal",nil, function(minp, maxp, blockseed)
if minp.y <= END_EXIT_PORTAL_POS.y and maxp.y >= END_EXIT_PORTAL_POS.y and
minp.x <= END_EXIT_PORTAL_POS.x and maxp.x >= END_EXIT_PORTAL_POS.x and
minp.z <= END_EXIT_PORTAL_POS.z and maxp.z >= END_EXIT_PORTAL_POS.z then
for y=maxp.y, minp.y, -1 do
local p = {x=END_EXIT_PORTAL_POS.x, y=y, z=END_EXIT_PORTAL_POS.z}
if minetest.get_node(p).name == "mcl_end:end_stone" then
generate_end_exit_portal(p)
return
end
end
generate_end_exit_portal(END_EXIT_PORTAL_POS)
end
end,101,true)