Partially re-implement Superflat

This commit is contained in:
Wuzzy 2017-02-23 00:15:47 +01:00
parent 85ce127e6b
commit 73957c46b2
3 changed files with 62 additions and 23 deletions

View File

@ -8,8 +8,19 @@ mcl_vars.gui_bg_img = ""
mcl_vars.inventory_header = mcl_vars.gui_slots .. mcl_vars.gui_bg mcl_vars.inventory_header = mcl_vars.gui_slots .. mcl_vars.gui_bg
local mg_name = minetest.get_mapgen_setting("mg_name")
if mg_name ~= "flat" then
-- 1 flat bedrock layer with 4 rough layers above
mcl_vars.bedrock_overworld_min = -62 mcl_vars.bedrock_overworld_min = -62
mcl_vars.bedrock_overworld_max = -58 mcl_vars.bedrock_overworld_max = mcl_vars.bedrock_overworld_min + 4
mcl_vars.bedrock_is_rough = true
else
-- 1 perfectly flat bedrock layer
local ground = minetest.get_mapgen_setting("mgflat_ground_level")
mcl_vars.bedrock_overworld_min = ground - 3
mcl_vars.bedrock_overworld_max = mcl_vars.bedrock_overworld_min
mcl_vars.bedrock_is_rough = false
end
-- Set default stack sizes -- Set default stack sizes
minetest.nodedef_default.stack_max = 64 minetest.nodedef_default.stack_max = 64

View File

@ -1,11 +1,25 @@
-- --
-- Register biomes -- Register biomes for mapgens other than v6
-- EXPERIMENTAL! -- EXPERIMENTAL!
-- --
-- All mapgens except mgv6 and singlenode local function register_classic_superflat_biome()
-- Classic Superflat: bedrock (not part of biome), 2 dirt, 1 grass block
minetest.register_biome({
name = "flat",
node_top = "mcl_core:dirt_with_grass",
depth_top = 1,
node_filler = "mcl_core:dirt",
depth_filler = 2,
y_min = 1,
y_max = 31000,
heat_point = 50,
humidity_point = 50,
})
end
-- All mapgens except mgv6, flat and singlenode
local function register_biomes() local function register_biomes()
minetest.register_biome({ minetest.register_biome({
@ -227,7 +241,10 @@ end
-- Detect mapgen to select functions -- Detect mapgen to select functions
-- --
local mg_name = minetest.get_mapgen_setting("mg_name") local mg_name = minetest.get_mapgen_setting("mg_name")
if mg_name ~= "v6" then if mg_name ~= "v6" and mg_name ~= "flat" then
register_biomes() register_biomes()
register_decorations() register_decorations()
elseif mg_name == "flat" then
-- Implementation of Minecraft's Superflat mapgen, classic style
register_classic_superflat_biome()
end end

View File

@ -466,7 +466,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end) end)
-- Generate 5 layers of bedrock, with increasing levels of roughness, until a perfecly flat bedrock later at the bottom layer -- Generate bedrock layer or layers
local BEDROCK_MIN = mcl_vars.bedrock_overworld_min local BEDROCK_MIN = mcl_vars.bedrock_overworld_min
local BEDROCK_MAX = mcl_vars.bedrock_overworld_max local BEDROCK_MAX = mcl_vars.bedrock_overworld_max
@ -486,6 +486,9 @@ minetest.register_on_generated(function(minp, maxp)
for z = minp.z, maxp.z do for z = minp.z, maxp.z do
local p_pos = area:index(x, y, z) local p_pos = area:index(x, y, z)
local setdata = nil local setdata = nil
if mcl_vars.bedrock_is_rough then
-- 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.
if y == BEDROCK_MAX then if y == BEDROCK_MAX then
-- 50% bedrock chance -- 50% bedrock chance
if math.random(1,2) == 1 then setdata = c_bedrock end if math.random(1,2) == 1 then setdata = c_bedrock end
@ -504,6 +507,14 @@ minetest.register_on_generated(function(minp, maxp)
elseif y < BEDROCK_MIN then elseif y < BEDROCK_MIN then
setdata = c_void setdata = c_void
end end
else
-- Perfectly flat bedrock layer(s)
if y >= BEDROCK_MIN and y <= BEDROCK_MAX then
setdata = c_bedrock
elseif y < BEDROCK_MIN then
setdata = c_void
end
end
if setdata then if setdata then
data[p_pos] = setdata data[p_pos] = setdata
end end