1
0
Fork 0

Add helper functions to convert to/from MC layer

This commit is contained in:
Wuzzy 2017-03-04 22:45:08 +01:00
parent 7a4b107d75
commit 19150ddddb
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1 @@
mcl_init

View File

@ -205,3 +205,26 @@ function mcl_util.is_in_void(pos)
return void, void_deadly return void, void_deadly
end end
-- Here come 2 simple converter functions which are important for map generators and mob spawning
-- Takes an Y coordinate as input and returns:
-- 1) The corresponding Minecraft layer (can be nil if void)
-- 2) The corresponding Minecraft dimension ("overworld", "nether" or "end") or "void" if it is in the void
-- If the Y coordinate is not located in any dimension, it will return:
-- nil, "void"
function mcl_util.y_to_layer(y)
if y >= mcl_vars.bedrock_overworld_min then
return y - mcl_vars.bedrock_overworld_min, "overworld"
else
return nil, "void"
end
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.bedrock_overworld_min
end