mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 13:53:45 +01:00
Set proper realm boundaries
This commit is contained in:
parent
91b92a2cfd
commit
860155e5c1
@ -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 mg_name = minetest.get_mapgen_setting("mg_name")
|
||||||
local minecraft_height_limit = 256
|
local minecraft_height_limit = 256
|
||||||
if mg_name ~= "flat" then
|
if mg_name ~= "flat" then
|
||||||
mcl_vars.mg_overworld_min = -62
|
--[[ Realm stacking (h is for height)
|
||||||
mcl_vars.mg_overworld_max = mcl_vars.mg_overworld_min + minecraft_height_limit
|
- 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_min = mcl_vars.mg_overworld_min
|
||||||
mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min + 4
|
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_overworld_max = mcl_vars.mg_overworld_min + 10
|
||||||
mcl_vars.mg_lava = true
|
mcl_vars.mg_lava = true
|
||||||
mcl_vars.mg_bedrock_is_rough = true
|
mcl_vars.mg_bedrock_is_rough = true
|
||||||
|
|
||||||
else
|
else
|
||||||
local ground = minetest.get_mapgen_setting("mgflat_ground_level")
|
local ground = minetest.get_mapgen_setting("mgflat_ground_level")
|
||||||
ground = tonumber(ground)
|
ground = tonumber(ground)
|
||||||
@ -33,13 +43,28 @@ else
|
|||||||
else
|
else
|
||||||
mcl_vars.mg_overworld_min = ground - 3
|
mcl_vars.mg_overworld_min = ground - 3
|
||||||
end
|
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_min = mcl_vars.mg_overworld_min
|
||||||
mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min
|
mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min
|
||||||
mcl_vars.mg_lava = false
|
mcl_vars.mg_lava = false
|
||||||
mcl_vars.mg_bedrock_is_rough = false
|
mcl_vars.mg_bedrock_is_rough = false
|
||||||
end
|
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
|
-- Set default stack sizes
|
||||||
minetest.nodedef_default.stack_max = 64
|
minetest.nodedef_default.stack_max = 64
|
||||||
minetest.craftitemdef_default.stack_max = 64
|
minetest.craftitemdef_default.stack_max = 64
|
||||||
|
@ -335,9 +335,23 @@ end
|
|||||||
-- 1st return value: true if pos is in void
|
-- 1st return value: true if pos is in void
|
||||||
-- 2nd return value: true if it is in the deadly part of the void
|
-- 2nd return value: true if it is in the deadly part of the void
|
||||||
function mcl_util.is_in_void(pos)
|
function mcl_util.is_in_void(pos)
|
||||||
local void, void_deadly
|
local void =
|
||||||
void = pos.y < mcl_vars.mg_overworld_min
|
not ((pos.y < mcl_vars.mg_overworld_max and pos.y > mcl_vars.mg_overworld_min) or
|
||||||
void_deadly = pos.y < mcl_vars.mg_overworld_min - 64
|
(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
|
return void, void_deadly
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -351,6 +365,10 @@ end
|
|||||||
function mcl_util.y_to_layer(y)
|
function mcl_util.y_to_layer(y)
|
||||||
if y >= mcl_vars.mg_overworld_min then
|
if y >= mcl_vars.mg_overworld_min then
|
||||||
return y - mcl_vars.mg_overworld_min, "overworld"
|
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
|
else
|
||||||
return nil, "void"
|
return nil, "void"
|
||||||
end
|
end
|
||||||
@ -359,10 +377,15 @@ end
|
|||||||
-- Takes a Minecraft layer and a “dimension” name
|
-- Takes a Minecraft layer and a “dimension” name
|
||||||
-- and returns the corresponding Y coordinate for
|
-- and returns the corresponding Y coordinate for
|
||||||
-- MineClone 2.
|
-- MineClone 2.
|
||||||
-- minecraft_dimension parameter is ignored at the moment
|
-- mc_dimension is one of "overworld", "nether", "end" (default: "overworld").
|
||||||
-- TODO: Implement dimensions
|
function mcl_util.layer_to_y(layer, mc_dimension)
|
||||||
function mcl_util.layer_to_y(layer, minecraft_dimension)
|
if mc_dimension == "overworld" or mc_dimension == nil then
|
||||||
return layer + mcl_vars.mg_overworld_min
|
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
|
end
|
||||||
|
|
||||||
-- Returns a on_place function for plants
|
-- Returns a on_place function for plants
|
||||||
|
@ -1227,33 +1227,49 @@ minetest.register_on_generated(function(minp, maxp)
|
|||||||
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.mg_bedrock_is_rough then
|
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
|
local is_bedrock = function(y)
|
||||||
-- This code assumes a bedrock height of 5 layers.
|
-- Bedrock layers with increasing levels of roughness, until a perfecly flat bedrock later at the bottom layer
|
||||||
if y == BEDROCK_MAX then
|
-- This code assumes a bedrock height of 5 layers.
|
||||||
-- 50% bedrock chance
|
|
||||||
if math.random(1,2) == 1 then setdata = c_bedrock end
|
local diff = mcl_vars.mg_bedrock_overworld_max - y -- Overworld bedrock
|
||||||
elseif y == BEDROCK_MAX -1 then
|
local ndiff1 = mcl_vars.mg_bedrock_nether_bottom_max - y -- Nether bedrock, bottom
|
||||||
-- 66.666...%
|
local ndiff2 = mcl_vars.mg_bedrock_nether_top_max - y -- Nether bedrock, ceiling
|
||||||
if math.random(1,3) <= 2 then setdata = c_bedrock end
|
|
||||||
elseif y == BEDROCK_MAX -2 then
|
local top
|
||||||
-- 75%
|
if diff == 0 or ndiff1 == 0 or ndiff2 == 4 then
|
||||||
if math.random(1,4) <= 3 then setdata = c_bedrock end
|
-- 50% bedrock chance
|
||||||
elseif y == BEDROCK_MAX -3 then
|
top = 2
|
||||||
-- 90%
|
elseif diff == 1 or ndiff1 == 1 or ndiff2 == 3 then
|
||||||
if math.random(1,10) <= 9 then setdata = c_bedrock end
|
-- 66.666...%
|
||||||
elseif y == BEDROCK_MAX -4 then
|
top = 3
|
||||||
-- 100%
|
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
|
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
|
setdata = c_void
|
||||||
elseif y > 1000 and y < 2000 then
|
|
||||||
setdata = c_stone
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- Perfectly flat bedrock layer(s)
|
-- 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
|
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
|
setdata = c_void
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user