forked from VoxeLibre/VoxeLibre
Compare commits
1 Commits
master
...
flatconfig
Author | SHA1 | Date |
---|---|---|
Wuzzy | c25d3e574a |
|
@ -24,13 +24,40 @@ else
|
||||||
if not ground then
|
if not ground then
|
||||||
ground = 8
|
ground = 8
|
||||||
end
|
end
|
||||||
mcl_vars.mg_overworld_min = ground - 1
|
local layer_setting = minetest.get_mapgen_setting("mcl_superflat_layers")
|
||||||
mcl_vars.mg_overworld_max = mcl_vars.mg_overworld_min + minecraft_height_limit
|
local layers
|
||||||
|
if layer_setting then
|
||||||
|
layers = {}
|
||||||
|
local s_version, s_layers, _, _ = string.split(layer_setting, ";", true, 4)
|
||||||
|
if tonumber(s_version) == 3 then
|
||||||
|
local split_layers = string.split(s_layers, ",")
|
||||||
|
if split_layers then
|
||||||
|
for s=1, #split_layers do
|
||||||
|
local node, repetitions = string.match(split_layers[s], "([0-9a-zA-Z:]+)%*([0-9]+)")
|
||||||
|
if not node then
|
||||||
|
node = string.match(split_layers[s], "([0-9a-zA-Z:]+)")
|
||||||
|
repetitions = 1
|
||||||
|
end
|
||||||
|
for r=1, repetitions do
|
||||||
|
table.insert(layers, node)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not layers then
|
||||||
|
layers = {
|
||||||
|
"mcl_core:bedrock",
|
||||||
|
"mcl_core:dirt",
|
||||||
|
"mcl_core:dirt",
|
||||||
|
"mcl_core:dirt_with_grass",
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
-- 1 perfectly flat bedrock layer
|
mcl_vars.mg_flat_layers = layers
|
||||||
mcl_vars.mg_bedrock_overworld_min = mcl_vars.mg_overworld_min - 2
|
|
||||||
mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min
|
mcl_vars.mg_overworld_min = ground - #layers + 1
|
||||||
mcl_vars.mg_bedrock_is_rough = false
|
mcl_vars.mg_overworld_max = mcl_vars.mg_overworld_min + minecraft_height_limit
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set default stack sizes
|
-- Set default stack sizes
|
||||||
|
|
|
@ -74,7 +74,7 @@ skycolor = {
|
||||||
players = skycolor.utils.get_players(players)
|
players = skycolor.utils.get_players(players)
|
||||||
for _, player in ipairs(players) do
|
for _, player in ipairs(players) do
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
if pos.y >= mcl_vars.mg_bedrock_overworld_max then
|
if pos.y >= mcl_vars.mg_overworld_min then
|
||||||
player:set_sky(color, "plain", nil)
|
player:set_sky(color, "plain", nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -112,7 +112,7 @@ skycolor = {
|
||||||
local players = skycolor.utils.get_players(nil)
|
local players = skycolor.utils.get_players(nil)
|
||||||
for _, player in ipairs(players) do
|
for _, player in ipairs(players) do
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
if pos.y >= mcl_vars.mg_bedrock_overworld_max then
|
if pos.y >= mcl_vars.mg_overworld_min then
|
||||||
player:set_sky(color, "plain", nil)
|
player:set_sky(color, "plain", nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -125,7 +125,7 @@ skycolor = {
|
||||||
local players = skycolor.utils.get_players(players)
|
local players = skycolor.utils.get_players(players)
|
||||||
for _, player in ipairs(players) do
|
for _, player in ipairs(players) do
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
if pos.y >= mcl_vars.mg_bedrock_overworld_max then
|
if pos.y >= mcl_vars.mg_overworld_min then
|
||||||
player:set_sky(nil, "regular", nil)
|
player:set_sky(nil, "regular", nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -255,5 +255,5 @@ elseif mg_name == "flat" then
|
||||||
minetest.clear_registered_biomes()
|
minetest.clear_registered_biomes()
|
||||||
minetest.clear_registered_decorations()
|
minetest.clear_registered_decorations()
|
||||||
minetest.clear_registered_schematics()
|
minetest.clear_registered_schematics()
|
||||||
register_classic_superflat_biome()
|
-- register_classic_superflat_biome()
|
||||||
end
|
end
|
||||||
|
|
|
@ -794,7 +794,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
num_water_around = num_water_around + 1 end
|
num_water_around = num_water_around + 1 end
|
||||||
if num_water_around >= 2 then
|
if num_water_around >= 2 then
|
||||||
is_shallow = false
|
is_shallow = false
|
||||||
end
|
end
|
||||||
if is_shallow then
|
if is_shallow then
|
||||||
for x1=-divlen,divlen do
|
for x1=-divlen,divlen do
|
||||||
for z1=-divlen,divlen do
|
for z1=-divlen,divlen do
|
||||||
|
@ -862,7 +862,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ground_y then
|
if ground_y then
|
||||||
local p = {x=x,y=ground_y+1,z=z}
|
local p = {x=x,y=ground_y+1,z=z}
|
||||||
local nn = minetest.get_node(p).name
|
local nn = minetest.get_node(p).name
|
||||||
|
@ -880,7 +880,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -888,14 +888,63 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
local mg_name = minetest.get_mapgen_setting("mg_name")
|
||||||
|
|
||||||
-- Generate bedrock layer or layers
|
-- Generate bedrock layer or layers
|
||||||
local BEDROCK_MIN = mcl_vars.mg_bedrock_overworld_min
|
local BEDROCK_MIN = mcl_vars.mg_bedrock_overworld_min
|
||||||
local BEDROCK_MAX = mcl_vars.mg_bedrock_overworld_max
|
local BEDROCK_MAX = mcl_vars.mg_bedrock_overworld_max
|
||||||
|
|
||||||
-- Below the bedrock, generate air/void
|
-- Below the bedrock, generate air/void
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp)
|
minetest.register_on_generated(function(minp, maxp)
|
||||||
if minp.y <= BEDROCK_MAX then
|
if mg_name == "flat" then
|
||||||
|
if minp.y <= mcl_vars.mg_overworld_max then--and minp.y <= (mcl_vars.mg_overworld_min + mcl_vars.mg_flat_layer_count) then
|
||||||
|
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||||
|
local data = vm:get_data()
|
||||||
|
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
|
||||||
|
|
||||||
|
local c_void = minetest.get_content_id("mcl_core:void")
|
||||||
|
|
||||||
|
local node_ids = {}
|
||||||
|
local get_content_id = function(nodename)
|
||||||
|
if not node_ids[nodename] then
|
||||||
|
node_ids[nodename] = minetest.get_content_id(nodename)
|
||||||
|
end
|
||||||
|
return node_ids[nodename]
|
||||||
|
end
|
||||||
|
|
||||||
|
local layer_counter = 1
|
||||||
|
local repeat_counter = 1
|
||||||
|
|
||||||
|
local max = math.min(maxp.y, mcl_vars.mg_overworld_max)
|
||||||
|
max = math.min(max, mcl_vars.mg_overworld_min + #mcl_vars.mg_flat_layers)
|
||||||
|
for y = minp.y, max do
|
||||||
|
for x = minp.x, maxp.x do
|
||||||
|
for z = minp.z, maxp.z do
|
||||||
|
local p_pos = area:index(x, y, z)
|
||||||
|
|
||||||
|
if y < mcl_vars.mg_overworld_min then
|
||||||
|
data[p_pos] = c_void
|
||||||
|
else
|
||||||
|
local layer = mcl_util.y_to_layer(y)
|
||||||
|
local nodename = mcl_vars.mg_flat_layers[layer+1]
|
||||||
|
if nodename then
|
||||||
|
data[p_pos] = get_content_id(nodename)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
vm:set_data(data)
|
||||||
|
vm:calc_lighting()
|
||||||
|
vm:update_liquids()
|
||||||
|
vm:write_to_map()
|
||||||
|
|
||||||
|
end
|
||||||
|
elseif minp.y <= BEDROCK_MAX then
|
||||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
|
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
|
||||||
|
@ -951,7 +1000,6 @@ minetest.register_on_generated(function(minp, maxp)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Apply mapgen-specific mapgen code
|
-- Apply mapgen-specific mapgen code
|
||||||
local mg_name = minetest.get_mapgen_setting("mg_name")
|
|
||||||
if mg_name == "v6" then
|
if mg_name == "v6" then
|
||||||
register_mgv6_decorations()
|
register_mgv6_decorations()
|
||||||
end
|
end
|
||||||
|
|
|
@ -121,7 +121,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Apply black sky in the Void and deal Void damage
|
-- Apply black sky in the Void and deal Void damage
|
||||||
if pos.y < mcl_vars.mg_bedrock_overworld_max then
|
if pos.y < mcl_vars.mg_overworld_min then
|
||||||
-- Player reached the void, set black sky box
|
-- Player reached the void, set black sky box
|
||||||
player:set_sky("#000000", "plain")
|
player:set_sky("#000000", "plain")
|
||||||
-- FIXME: Sky handling in MCL2 is held together with lots of duct tape.
|
-- FIXME: Sky handling in MCL2 is held together with lots of duct tape.
|
||||||
|
|
Loading…
Reference in New Issue