1
0
Fork 0

Set proper realm boundaries

objects
Wuzzy 2017-08-16 15:29:05 +02:00
parent 91b92a2cfd
commit 860155e5c1
3 changed files with 96 additions and 32 deletions

View File

@ -12,15 +12,25 @@ mcl_vars.inventory_header = mcl_vars.gui_slots .. mcl_vars.gui_bg
local mg_name = minetest.get_mapgen_setting("mg_name")
local minecraft_height_limit = 256
if mg_name ~= "flat" then
mcl_vars.mg_overworld_min = -62
mcl_vars.mg_overworld_max = mcl_vars.mg_overworld_min + minecraft_height_limit
--[[ Realm stacking (h is for height)
- Overworld (h>=256)
- Void (h>=1000)
- Realm Barrier (h=11), to allow escaping the End
- End (h>=256)
- Void (h>=1000)
- Nether (h=128)
- Void (h>=1000)
]]
-- 1 flat bedrock layer with 4 rough layers above
-- 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
else
local ground = minetest.get_mapgen_setting("mgflat_ground_level")
ground = tonumber(ground)
@ -33,13 +43,28 @@ else
else
mcl_vars.mg_overworld_min = ground - 3
end
mcl_vars.mg_overworld_max = mcl_vars.mg_overworld_min + minecraft_height_limit
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_bedrock_is_rough = false
end
mcl_vars.mg_overworld_max = math.huge
-- The Nether
mcl_vars.mg_nether_min = -29000
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_bottom_max = mcl_vars.mg_bedrock_nether_bottom_min + 4
mcl_vars.mg_bedrock_nether_top_max = mcl_vars.mg_nether_max
mcl_vars.mg_bedrock_nether_top_min = mcl_vars.mg_bedrock_nether_top_max - 4
-- The End
mcl_vars.mg_end_min = mcl_vars.mg_nether_max + 2000
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
-- Set default stack sizes
minetest.nodedef_default.stack_max = 64
minetest.craftitemdef_default.stack_max = 64

View File

@ -335,9 +335,23 @@ end
-- 1st return value: true if pos is in void
-- 2nd return value: true if it is in the deadly part of the void
function mcl_util.is_in_void(pos)
local void, void_deadly
void = pos.y < mcl_vars.mg_overworld_min
void_deadly = pos.y < mcl_vars.mg_overworld_min - 64
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 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 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 then
void_deadly = pos.y < mcl_vars.mg_end_min - deadly_tolerance
elseif pos.y < mcl_vars.mg_nether_min then
void_deadly = pos.y < mcl_vars.mg_nether_min - deadly_tolerance
end
end
return void, void_deadly
end
@ -351,6 +365,10 @@ end
function mcl_util.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 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"
else
return nil, "void"
end
@ -359,10 +377,15 @@ end
-- Takes a Minecraft layer and a “dimension” name
-- and returns the corresponding Y coordinate for
-- MineClone 2.
-- minecraft_dimension parameter is ignored at the moment
-- TODO: Implement dimensions
function mcl_util.layer_to_y(layer, minecraft_dimension)
return layer + mcl_vars.mg_overworld_min
-- mc_dimension is one of "overworld", "nether", "end" (default: "overworld").
function mcl_util.layer_to_y(layer, mc_dimension)
if mc_dimension == "overworld" or mc_dimension == nil then
return layer + mcl_vars.mg_overworld_min
elseif mc_dimension == "nether" then
return layer + mcl_vars.mg_nether_min
elseif mc_dimension == "end" then
return layer + mcl_vars.mg_end_min
end
end
-- Returns a on_place function for plants

View File

@ -1227,33 +1227,49 @@ minetest.register_on_generated(function(minp, maxp)
local p_pos = area:index(x, y, z)
local setdata = nil
if mcl_vars.mg_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
-- 50% bedrock chance
if math.random(1,2) == 1 then setdata = c_bedrock end
elseif y == BEDROCK_MAX -1 then
-- 66.666...%
if math.random(1,3) <= 2 then setdata = c_bedrock end
elseif y == BEDROCK_MAX -2 then
-- 75%
if math.random(1,4) <= 3 then setdata = c_bedrock end
elseif y == BEDROCK_MAX -3 then
-- 90%
if math.random(1,10) <= 9 then setdata = c_bedrock end
elseif y == BEDROCK_MAX -4 then
-- 100%
local is_bedrock = function(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 math.random(1, top) <= top-1
end
if is_bedrock(y) then
setdata = c_bedrock
elseif y < BEDROCK_MIN and y > -1000 then
elseif mcl_util.is_in_void({x=x,y=y,z=z}) then
setdata = c_void
elseif y > 1000 and y < 2000 then
setdata = c_stone
end
else
-- Perfectly flat bedrock layer(s)
if y >= BEDROCK_MIN and y <= BEDROCK_MAX then
if (y >= mcl_vars.mg_bedrock_overworld_min and y <= mcl_vars.mg_bedrock_overworld_max) or
(y >= mcl_vars.mg_bedrock_nether_bottom_min or y <= mcl_vars.mg_bedrock_bottom_max) or
(y >= mcl_vars.mg_bedrock_nether_top_min or y <= mcl_vars.mg_bedrock_top_max) then
setdata = c_bedrock
elseif y < BEDROCK_MIN and y > -1000 then
elseif mcl_util.is_in_void({x=x,y=y,z=z}) then
setdata = c_void
end
end