Move world-related functions to mcl_worlds

This commit is contained in:
Wuzzy 2017-11-24 03:10:02 +01:00
parent 06ef86ddd3
commit b0c87f74fe
35 changed files with 212 additions and 202 deletions

@ -331,85 +331,6 @@ function mcl_util.is_fuel(item)
return minetest.get_craft_result({method="fuel", width=1, items={item}}).time ~= 0
end
-- For a given position, returns a 2-tuple:
-- 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 =
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
-- 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.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
end
-- Takes a Minecraft layer and a “dimension” name
-- and returns the corresponding Y coordinate for
-- MineClone 2.
-- 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
-- Takes a position and returns true if this position can have weather
function mcl_util.has_weather(pos)
-- Weather in the Overworld and the high part of the void below
return pos.y <= mcl_vars.mg_overworld_max and pos.y >= mcl_vars.mg_overworld_min - 64
end
-- Takes a position (pos) and returns true if compasses are working here
function mcl_util.compass_works(pos)
-- It doesn't work in Nether and the End, but it works in the Overworld and in the high part of the void below
local _, dim = mcl_util.y_to_layer(pos.y)
if dim == "nether" or dim == "end" then
return false
elseif dim == "void" then
return pos.y <= mcl_vars.mg_overworld_max and pos.y >= mcl_vars.mg_overworld_min - 64
else
return true
end
end
-- Takes a position (pos) and returns true if clocks are working here
mcl_util.clock_works = mcl_util.compass_works
-- Returns a on_place function for plants
-- * condition: function(pos, node, itemstack)
-- * A function which is called by the on_place function to check if the node can be placed

@ -0,0 +1 @@
mcl_init

@ -0,0 +1 @@
Utility functions for worlds and the “dimensions”.

@ -0,0 +1,85 @@
mcl_worlds = {}
-- For a given position, returns a 2-tuple:
-- 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_worlds.is_in_void(pos)
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
-- 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_worlds.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
end
-- Takes a pos and returns the dimension it belongs to (same as above)
function mcl_worlds.pos_to_dimension(pos)
local _, dim = mcl_worlds.y_to_layer(pos.y)
return dim
end
-- Takes a Minecraft layer and a “dimension” name
-- and returns the corresponding Y coordinate for
-- MineClone 2.
-- mc_dimension is one of "overworld", "nether", "end" (default: "overworld").
function mcl_worlds.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
-- Takes a position and returns true if this position can have weather
function mcl_worlds.has_weather(pos)
-- Weather in the Overworld and the high part of the void below
return pos.y <= mcl_vars.mg_overworld_max and pos.y >= mcl_vars.mg_overworld_min - 64
end
-- Takes a position (pos) and returns true if compasses are working here
function mcl_worlds.compass_works(pos)
-- It doesn't work in Nether and the End, but it works in the Overworld and in the high part of the void below
local _, dim = mcl_worlds.y_to_layer(pos.y)
if dim == "nether" or dim == "end" then
return false
elseif dim == "void" then
return pos.y <= mcl_vars.mg_overworld_max and pos.y >= mcl_vars.mg_overworld_min - 64
else
return true
end
end
-- Takes a position (pos) and returns true if clocks are working here
mcl_worlds.clock_works = mcl_worlds.compass_works

@ -1,3 +1,3 @@
mcl_init
mcl_util
mcl_worlds
lightning?

@ -164,7 +164,7 @@ mcl_weather.rain.make_weather = function()
end
for _, player in ipairs(minetest.get_connected_players()) do
if (mcl_weather.is_underwater(player) or not mcl_util.has_weather(player:getpos())) then
if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:getpos())) then
mcl_weather.rain.remove_sound(player)
return false
end

@ -74,7 +74,7 @@ mcl_weather.skycolor = {
local color = mcl_weather.skycolor.current_sky_layer_color()
for _, player in ipairs(players) do
local pos = player:get_pos()
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "overworld" then
if (color == nil) then
-- No sky layers
@ -141,7 +141,7 @@ mcl_weather.skycolor = {
local players = mcl_weather.skycolor.utils.get_players(nil)
for _, player in ipairs(players) do
local pos = player:getpos()
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "overworld" then
player:set_sky(color, "plain", nil, true)
end
@ -235,7 +235,7 @@ local initsky = function(player)
end
-- MC-style clouds: Layer 127, thickness 4, fly to the “West”
player:set_clouds({height=mcl_util.layer_to_y(127), speed={x=-2, y=0}, thickness=4, color="#FFF0FEF"})
player:set_clouds({height=mcl_worlds.layer_to_y(127), speed={x=-2, y=0}, thickness=4, color="#FFF0FEF"})
end
minetest.register_on_joinplayer(initsky)

@ -78,7 +78,7 @@ minetest.register_globalstep(function(dtime)
end
for _, player in ipairs(minetest.get_connected_players()) do
if (mcl_weather.is_underwater(player) or not mcl_util.has_weather(player:getpos())) then
if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:getpos())) then
return false
end
mcl_weather.snow.add_snow_particles(player)

@ -61,7 +61,7 @@ end
-- FIXME: Nodes below glass also count as “outdoor”, this should not be the case.
mcl_weather.is_outdoor = function(pos)
local cpos = {x=pos.x, y=pos.y+1, z=pos.z}
local _, dim = mcl_util.y_to_layer(cpos.y)
local dim = mcl_worlds.pos_to_dimension(cpos)
if minetest.get_node_light(cpos, 0.5) == 15 and dim == "overworld" then
return true
end

@ -2,7 +2,7 @@ mcl_init
mesecons
mcl_sounds
mcl_tnt
mcl_util
mcl_worlds
mcl_core
mcl_nether
3d_armor_stand

@ -173,7 +173,7 @@ local dispenserdef = {
elseif iname == "mcl_buckets:bucket_water" or iname == "mcl_buckets:bucket_lava" then
-- Place water/lava source
if dropnodedef.buildable_to then
local _, dim = mcl_util.y_to_layer(droppos.y)
local dim = mcl_worlds.pos_to_dimension(droppos)
if iname == "mcl_buckets:bucket_water" then
if dim == "nether" then
minetest.sound_play("fire_extinguish_flame", {pos = droppos, gain = 0.25, max_hear_distance = 16})

@ -1,5 +1,5 @@
mcl_sounds?
mcl_util?
mcl_worlds?
mcl_wool?
mcl_dye?
mcl_tnt?

@ -162,8 +162,8 @@ function mcl_beds.on_rightclick(pos, player)
if player:get_attribute("mcl_beds:sleeping") == "true" then
return
end
if minetest.get_modpath("mcl_init") then
local _, dim = mcl_util.y_to_layer(pos.y)
if minetest.get_modpath("mcl_worlds") then
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "nether" or dim == "end" then
-- Bed goes BOOM in the Nether or End.
minetest.remove_node(pos)

@ -1,2 +1,3 @@
mcl_worlds
mcl_core?
doc?

@ -251,7 +251,7 @@ if mod_mcl_core then
return false
-- Evaporate water if used in Nether (except on cauldron)
else
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "nether" then
minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16})
return false
@ -263,7 +263,7 @@ if mod_mcl_core then
-- Lava bucket
mcl_buckets.register_liquid(
function(pos)
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "nether" then
return "mcl_nether:nether_lava_source"
else

@ -1,4 +1,4 @@
mcl_init
mcl_util
mcl_worlds
mesecons
doc?

@ -89,10 +89,10 @@ minetest.register_globalstep(function(dtime)
local players = minetest.get_connected_players()
for p, player in ipairs(players) do
for s, stack in ipairs(player:get_inventory():get_list("main")) do
local _, dim = mcl_util.y_to_layer(player:getpos().y)
local dim = mcl_worlds.pos_to_dimension(player:get_pos())
local frame
-- Clocks do not work in certain zones
if not mcl_util.clock_works(player:getpos()) then
if not mcl_worlds.clock_works(player:getpos()) then
frame = random_frame
else
frame = now

@ -1,4 +1,4 @@
mcl_core
mcl_util
mcl_worlds
mesecons
doc?

@ -29,10 +29,10 @@ minetest.register_globalstep(function(dtime)
end
if has_compass(player) then
local pos = player:getpos()
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
local compass_image
-- Compasses do not work in certain zones
if not mcl_util.compass_works(pos) then
if not mcl_worlds.compass_works(pos) then
compass_image = random_frame
else
local spawn = {x=0,y=0,z=0}

@ -1,5 +1,6 @@
mcl_init
mcl_sounds
mcl_util
mcl_worlds
doc_items
doc?

@ -321,7 +321,7 @@ minetest.register_node("mcl_core:dirt_with_grass", {
footstep = {name="default_grass_footstep", gain=0.4},
}),
on_construct = function(pos)
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
local dry
if dim == "nether" then
dry = true
@ -651,7 +651,7 @@ minetest.register_node("mcl_core:bedrock", {
end,
_on_ignite = function(player, pointed_thing)
local pos = pointed_thing.under
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
local flame_pos = {x = pos.x, y = pos.y + 1, z = pos.z}
local fn = minetest.get_node(flame_pos)
if dim == "end" and fn.name == "air" and not minetest.is_protected(flame_pos, "fire") and pointed_thing.under.y < pointed_thing.above.y then
@ -788,7 +788,7 @@ minetest.register_node("mcl_core:ice", {
-- Create a water source if ice is destroyed and there was something below it
local below = {x=pos.x, y=pos.y-1, z=pos.z}
local belownode = minetest.get_node(below)
local _, dim = mcl_util.y_to_layer(below.y)
local dim = mcl_worlds.pos_to_dimension(below)
if dim ~= "nether" and belownode.name ~= "air" and belownode.name ~= "ignore" and belownode.name ~= "mcl_core:void" then
minetest.set_node(pos, {name="mcl_core:water_source"})
end
@ -817,7 +817,7 @@ for i=0,3 do
-- Increase age of frosted age or turn to water source if too old
local nn = minetest.get_node(pos).name
local age = tonumber(string.sub(nn, -1))
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
if age == nil then return end
if age < 3 then
minetest.swap_node(pos, { name = "mcl_core:frosted_ice_"..(age+1) })

@ -1,4 +1,4 @@
mcl_core
mcl_util
mcl_worlds
mcl_sounds
mcl_portals?

@ -77,7 +77,7 @@ minetest.register_node("mcl_fire:fire", {
local bpos = {x=pos.x, y=pos.y-1, z=pos.z}
local under = minetest.get_node(bpos).name
local _, dim = mcl_util.y_to_layer(bpos.y)
local dim = mcl_worlds.pos_to_dimension(bpos)
if under == "mcl_nether:magma" or under == "mcl_nether:netherrack" or (under == "mcl_core:bedrock" and dim == "end") then
minetest.swap_node(pos, {name = "mcl_fire:eternal_fire"})
end

@ -1,5 +1,5 @@
mcl_init
mcl_util
mcl_worlds
mcl_core
mcl_nether
mcl_end

@ -200,7 +200,7 @@ minetest.register_abm({
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
local lua_entity = obj:get_luaentity() --maikerumine added for objects to travel
if obj:is_player() or lua_entity then
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
local objpos = obj:getpos()
if objpos == nil then
@ -263,7 +263,7 @@ minetest.register_abm({
-- Teleport
obj:set_pos(target)
if obj:is_player() then
-- Look towards the End island
-- Look towards the main End island
if dim ~= "end" then
obj:set_look_horizontal(math.pi/2)
end

@ -289,7 +289,7 @@ end
-- Returns true on success and false on failure.
function mcl_portals.light_nether_portal(pos)
-- Only allow to make portals in Overworld and Nether
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
if dim ~= "overworld" and dim ~= "nether" then
return false
end
@ -433,7 +433,7 @@ minetest.register_abm({
end
-- Teleport
obj:setpos(target)
obj:set_pos(target)
if obj:is_player() then
minetest.sound_play("mcl_portals_teleport", {pos=target, gain=0.5, max_hear_distance = 16})
end
@ -469,7 +469,7 @@ minetest.override_item("mcl_core:obsidian", {
doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal")
-- Achievement for finishing a Nether portal TO the Nether
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
if minetest.get_modpath("awards") and dim ~= "nether" and user:is_player() then
awards.unlock(user:get_player_name(), "mcl:buildNetherPortal")
end

@ -1,4 +1,5 @@
mcl_init
mcl_core
mcl_worlds
mcl_farming
mcl_flowers

@ -1407,7 +1407,7 @@ local function register_dimension_ores()
clust_scarcity = 13 * 13 * 13,
clust_size = 5,
y_min = mcl_vars.mg_nether_min,
y_max = mcl_util.layer_to_y(64, "nether"),
y_max = mcl_worlds.layer_to_y(64, "nether"),
noise_threshold = 0.0,
noise_params = {
offset = 0.5,
@ -1427,8 +1427,8 @@ local function register_dimension_ores()
clust_scarcity = 8*8*8,
clust_num_ores = 45,
clust_size = 6,
y_min = mcl_util.layer_to_y(23, "nether"),
y_max = mcl_util.layer_to_y(37, "nether"),
y_min = mcl_worlds.layer_to_y(23, "nether"),
y_max = mcl_worlds.layer_to_y(37, "nether"),
})
minetest.register_ore({
ore_type = "blob",
@ -1437,8 +1437,8 @@ local function register_dimension_ores()
clust_scarcity = 10*10*10,
clust_num_ores = 65,
clust_size = 8,
y_min = mcl_util.layer_to_y(23, "nether"),
y_max = mcl_util.layer_to_y(37, "nether"),
y_min = mcl_worlds.layer_to_y(23, "nether"),
y_max = mcl_worlds.layer_to_y(37, "nether"),
})
-- Glowstone
@ -1469,9 +1469,9 @@ local function register_dimension_ores()
column_height_min = 1,
column_height_max = 1,
column_midpoint_factor = 0,
y_min = mcl_util.layer_to_y(63, "nether"),
y_min = mcl_worlds.layer_to_y(63, "nether"),
-- This should be 65, but for some reason with this setting, the sheet ore really stops at 65. o_O
y_max = mcl_util.layer_to_y(65+2, "nether"),
y_max = mcl_worlds.layer_to_y(65+2, "nether"),
noise_threshold = 0.2,
noise_params = {
offset = 0.0,

@ -1,6 +1,6 @@
mcl_init
mcl_util
mcl_core
mcl_worlds
mcl_cocoas
mcl_stairs
mcl_monster_eggs

@ -134,7 +134,7 @@ minetest.register_ore({
clust_num_ores = 33,
clust_size = 5,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_util.layer_to_y(111),
y_max = mcl_worlds.layer_to_y(111),
})
--
@ -150,7 +150,7 @@ minetest.register_ore({
clust_num_ores = 5,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_util.layer_to_y(50),
y_max = mcl_worlds.layer_to_y(50),
})
minetest.register_ore({
ore_type = "scatter",
@ -160,7 +160,7 @@ minetest.register_ore({
clust_num_ores = 8,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_util.layer_to_y(50),
y_max = mcl_worlds.layer_to_y(50),
})
minetest.register_ore({
ore_type = "scatter",
@ -170,7 +170,7 @@ minetest.register_ore({
clust_num_ores = 12,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_util.layer_to_y(50),
y_max = mcl_worlds.layer_to_y(50),
})
-- Medium-rare spawn
@ -181,8 +181,8 @@ minetest.register_ore({
clust_scarcity = 550*3,
clust_num_ores = 4,
clust_size = 2,
y_min = mcl_util.layer_to_y(51),
y_max = mcl_util.layer_to_y(80),
y_min = mcl_worlds.layer_to_y(51),
y_max = mcl_worlds.layer_to_y(80),
})
minetest.register_ore({
ore_type = "scatter",
@ -191,8 +191,8 @@ minetest.register_ore({
clust_scarcity = 525*3,
clust_num_ores = 6,
clust_size = 3,
y_min = mcl_util.layer_to_y(51),
y_max = mcl_util.layer_to_y(80),
y_min = mcl_worlds.layer_to_y(51),
y_max = mcl_worlds.layer_to_y(80),
})
minetest.register_ore({
ore_type = "scatter",
@ -201,8 +201,8 @@ minetest.register_ore({
clust_scarcity = 500*3,
clust_num_ores = 8,
clust_size = 3,
y_min = mcl_util.layer_to_y(51),
y_max = mcl_util.layer_to_y(80),
y_min = mcl_worlds.layer_to_y(51),
y_max = mcl_worlds.layer_to_y(80),
})
-- Rare spawn
@ -213,8 +213,8 @@ minetest.register_ore({
clust_scarcity = 600*3,
clust_num_ores = 3,
clust_size = 2,
y_min = mcl_util.layer_to_y(81),
y_max = mcl_util.layer_to_y(128),
y_min = mcl_worlds.layer_to_y(81),
y_max = mcl_worlds.layer_to_y(128),
})
minetest.register_ore({
ore_type = "scatter",
@ -223,8 +223,8 @@ minetest.register_ore({
clust_scarcity = 550*3,
clust_num_ores = 4,
clust_size = 3,
y_min = mcl_util.layer_to_y(81),
y_max = mcl_util.layer_to_y(128),
y_min = mcl_worlds.layer_to_y(81),
y_max = mcl_worlds.layer_to_y(128),
})
minetest.register_ore({
ore_type = "scatter",
@ -233,8 +233,8 @@ minetest.register_ore({
clust_scarcity = 500*3,
clust_num_ores = 5,
clust_size = 3,
y_min = mcl_util.layer_to_y(81),
y_max = mcl_util.layer_to_y(128),
y_min = mcl_worlds.layer_to_y(81),
y_max = mcl_worlds.layer_to_y(128),
})
--
@ -248,7 +248,7 @@ minetest.register_ore({
clust_num_ores = 5,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_util.layer_to_y(39),
y_max = mcl_worlds.layer_to_y(39),
})
minetest.register_ore({
ore_type = "scatter",
@ -257,8 +257,8 @@ minetest.register_ore({
clust_scarcity = 1660,
clust_num_ores = 4,
clust_size = 2,
y_min = mcl_util.layer_to_y(40),
y_max = mcl_util.layer_to_y(63),
y_min = mcl_worlds.layer_to_y(40),
y_max = mcl_worlds.layer_to_y(63),
})
--
@ -274,7 +274,7 @@ minetest.register_ore({
clust_num_ores = 5,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_util.layer_to_y(30),
y_max = mcl_worlds.layer_to_y(30),
})
minetest.register_ore({
ore_type = "scatter",
@ -284,7 +284,7 @@ minetest.register_ore({
clust_num_ores = 7,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_util.layer_to_y(30),
y_max = mcl_worlds.layer_to_y(30),
})
-- Rare spawn
@ -295,8 +295,8 @@ minetest.register_ore({
clust_scarcity = 13000,
clust_num_ores = 4,
clust_size = 2,
y_min = mcl_util.layer_to_y(31),
y_max = mcl_util.layer_to_y(33),
y_min = mcl_worlds.layer_to_y(31),
y_max = mcl_worlds.layer_to_y(33),
})
-- Bonus spawn in Mesa
@ -308,8 +308,8 @@ if mg_name ~= "v6" then
clust_scarcity = 3333,
clust_num_ores = 5,
clust_size = 3,
y_min = mcl_util.layer_to_y(32),
y_max = mcl_util.layer_to_y(79),
y_min = mcl_worlds.layer_to_y(32),
y_max = mcl_worlds.layer_to_y(79),
biomes = { "Mesa", "Mesa_sandlevel", "Mesa_ocean", "Mesa_deep_ocean", "Mesa_underground" },
})
end
@ -327,7 +327,7 @@ minetest.register_ore({
clust_num_ores = 4,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_util.layer_to_y(12),
y_max = mcl_worlds.layer_to_y(12),
})
minetest.register_ore({
ore_type = "scatter",
@ -337,7 +337,7 @@ minetest.register_ore({
clust_num_ores = 2,
clust_size = 2,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_util.layer_to_y(12),
y_max = mcl_worlds.layer_to_y(12),
})
minetest.register_ore({
ore_type = "scatter",
@ -347,7 +347,7 @@ minetest.register_ore({
clust_num_ores = 8,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_util.layer_to_y(12),
y_max = mcl_worlds.layer_to_y(12),
})
-- Rare spawn
@ -358,8 +358,8 @@ minetest.register_ore({
clust_scarcity = 20000,
clust_num_ores = 1,
clust_size = 1,
y_min = mcl_util.layer_to_y(13),
y_max = mcl_util.layer_to_y(15),
y_min = mcl_worlds.layer_to_y(13),
y_max = mcl_worlds.layer_to_y(15),
})
minetest.register_ore({
ore_type = "scatter",
@ -368,8 +368,8 @@ minetest.register_ore({
clust_scarcity = 20000,
clust_num_ores = 2,
clust_size = 2,
y_min = mcl_util.layer_to_y(13),
y_max = mcl_util.layer_to_y(15),
y_min = mcl_worlds.layer_to_y(13),
y_max = mcl_worlds.layer_to_y(15),
})
--
@ -385,7 +385,7 @@ minetest.register_ore({
clust_num_ores = 4,
clust_size = 3,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_util.layer_to_y(13),
y_max = mcl_worlds.layer_to_y(13),
})
minetest.register_ore({
ore_type = "scatter",
@ -395,7 +395,7 @@ minetest.register_ore({
clust_num_ores = 7,
clust_size = 4,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_util.layer_to_y(13),
y_max = mcl_worlds.layer_to_y(13),
})
-- Rare spawn
@ -406,8 +406,8 @@ minetest.register_ore({
clust_scarcity = 1000,
clust_num_ores = 4,
clust_size = 3,
y_min = mcl_util.layer_to_y(13),
y_max = mcl_util.layer_to_y(15),
y_min = mcl_worlds.layer_to_y(13),
y_max = mcl_worlds.layer_to_y(15),
})
minetest.register_ore({
ore_type = "scatter",
@ -416,8 +416,8 @@ minetest.register_ore({
clust_scarcity = 1600,
clust_num_ores = 7,
clust_size = 4,
y_min = mcl_util.layer_to_y(13),
y_max = mcl_util.layer_to_y(15),
y_min = mcl_worlds.layer_to_y(13),
y_max = mcl_worlds.layer_to_y(15),
})
--
@ -436,7 +436,7 @@ if mg_name == "v6" then
clust_num_ores = 1,
clust_size = 1,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_util.layer_to_y(29),
y_max = mcl_worlds.layer_to_y(29),
})
-- Rare spawn
minetest.register_ore({
@ -446,8 +446,8 @@ if mg_name == "v6" then
clust_scarcity = 21510,
clust_num_ores = 1,
clust_size = 1,
y_min = mcl_util.layer_to_y(30),
y_max = mcl_util.layer_to_y(32),
y_min = mcl_worlds.layer_to_y(30),
y_max = mcl_worlds.layer_to_y(32),
})
else
-- Generate in Extreme Hills biome only
@ -459,8 +459,8 @@ else
clust_scarcity = 16384,
clust_num_ores = 1,
clust_size = 1,
y_min = mcl_util.layer_to_y(4),
y_max = mcl_util.layer_to_y(32),
y_min = mcl_worlds.layer_to_y(4),
y_max = mcl_worlds.layer_to_y(32),
biomes = { "ExtremeHills", "ExtremeHills_beach", "ExtremeHills_ocean", "ExtremeHills_deep_ocean", "ExtremeHills_underground" },
})
end
@ -477,8 +477,8 @@ minetest.register_ore({
clust_scarcity = 10000,
clust_num_ores = 7,
clust_size = 4,
y_min = mcl_util.layer_to_y(14),
y_max = mcl_util.layer_to_y(16),
y_min = mcl_worlds.layer_to_y(14),
y_max = mcl_worlds.layer_to_y(16),
})
-- Rare spawn (below center)
@ -489,8 +489,8 @@ minetest.register_ore({
clust_scarcity = 12000,
clust_num_ores = 6,
clust_size = 3,
y_min = mcl_util.layer_to_y(10),
y_max = mcl_util.layer_to_y(13),
y_min = mcl_worlds.layer_to_y(10),
y_max = mcl_worlds.layer_to_y(13),
})
minetest.register_ore({
ore_type = "scatter",
@ -499,8 +499,8 @@ minetest.register_ore({
clust_scarcity = 14000,
clust_num_ores = 5,
clust_size = 3,
y_min = mcl_util.layer_to_y(6),
y_max = mcl_util.layer_to_y(9),
y_min = mcl_worlds.layer_to_y(6),
y_max = mcl_worlds.layer_to_y(9),
})
minetest.register_ore({
ore_type = "scatter",
@ -509,8 +509,8 @@ minetest.register_ore({
clust_scarcity = 16000,
clust_num_ores = 4,
clust_size = 3,
y_min = mcl_util.layer_to_y(2),
y_max = mcl_util.layer_to_y(5),
y_min = mcl_worlds.layer_to_y(2),
y_max = mcl_worlds.layer_to_y(5),
})
minetest.register_ore({
ore_type = "scatter",
@ -519,8 +519,8 @@ minetest.register_ore({
clust_scarcity = 18000,
clust_num_ores = 3,
clust_size = 2,
y_min = mcl_util.layer_to_y(0),
y_max = mcl_util.layer_to_y(2),
y_min = mcl_worlds.layer_to_y(0),
y_max = mcl_worlds.layer_to_y(2),
})
-- Rare spawn (above center)
@ -531,8 +531,8 @@ minetest.register_ore({
clust_scarcity = 12000,
clust_num_ores = 6,
clust_size = 3,
y_min = mcl_util.layer_to_y(17),
y_max = mcl_util.layer_to_y(20),
y_min = mcl_worlds.layer_to_y(17),
y_max = mcl_worlds.layer_to_y(20),
})
minetest.register_ore({
ore_type = "scatter",
@ -541,8 +541,8 @@ minetest.register_ore({
clust_scarcity = 14000,
clust_num_ores = 5,
clust_size = 3,
y_min = mcl_util.layer_to_y(21),
y_max = mcl_util.layer_to_y(24),
y_min = mcl_worlds.layer_to_y(21),
y_max = mcl_worlds.layer_to_y(24),
})
minetest.register_ore({
ore_type = "scatter",
@ -551,8 +551,8 @@ minetest.register_ore({
clust_scarcity = 16000,
clust_num_ores = 4,
clust_size = 3,
y_min = mcl_util.layer_to_y(25),
y_max = mcl_util.layer_to_y(28),
y_min = mcl_worlds.layer_to_y(25),
y_max = mcl_worlds.layer_to_y(28),
})
minetest.register_ore({
ore_type = "scatter",
@ -561,8 +561,8 @@ minetest.register_ore({
clust_scarcity = 18000,
clust_num_ores = 3,
clust_size = 2,
y_min = mcl_util.layer_to_y(29),
y_max = mcl_util.layer_to_y(32),
y_min = mcl_worlds.layer_to_y(29),
y_max = mcl_worlds.layer_to_y(32),
})
minetest.register_ore({
ore_type = "scatter",
@ -571,8 +571,8 @@ minetest.register_ore({
clust_scarcity = 32000,
clust_num_ores = 1,
clust_size = 1,
y_min = mcl_util.layer_to_y(31),
y_max = mcl_util.layer_to_y(32),
y_min = mcl_worlds.layer_to_y(31),
y_max = mcl_worlds.layer_to_y(32),
})
if mg_name ~= "flat" then
@ -586,8 +586,8 @@ minetest.register_ore({
clust_scarcity = 9000,
clust_num_ores = 1,
clust_size = 1,
y_min = mcl_util.layer_to_y(5),
y_max = mcl_util.layer_to_y(128),
y_min = mcl_worlds.layer_to_y(5),
y_max = mcl_worlds.layer_to_y(128),
})
-- Lava springs are rather common at -31 and below
@ -598,8 +598,8 @@ minetest.register_ore({
clust_scarcity = 2000,
clust_num_ores = 1,
clust_size = 1,
y_min = mcl_util.layer_to_y(1),
y_max = mcl_util.layer_to_y(10),
y_min = mcl_worlds.layer_to_y(1),
y_max = mcl_worlds.layer_to_y(10),
})
minetest.register_ore({
@ -609,8 +609,8 @@ minetest.register_ore({
clust_scarcity = 9000,
clust_num_ores = 1,
clust_size = 1,
y_min = mcl_util.layer_to_y(11),
y_max = mcl_util.layer_to_y(31),
y_min = mcl_worlds.layer_to_y(11),
y_max = mcl_worlds.layer_to_y(31),
})
-- Lava springs will become gradually rarer with increasing height
@ -621,8 +621,8 @@ minetest.register_ore({
clust_scarcity = 32000,
clust_num_ores = 1,
clust_size = 1,
y_min = mcl_util.layer_to_y(32),
y_max = mcl_util.layer_to_y(47),
y_min = mcl_worlds.layer_to_y(32),
y_max = mcl_worlds.layer_to_y(47),
})
minetest.register_ore({
@ -632,8 +632,8 @@ minetest.register_ore({
clust_scarcity = 72000,
clust_num_ores = 1,
clust_size = 1,
y_min = mcl_util.layer_to_y(48),
y_max = mcl_util.layer_to_y(61),
y_min = mcl_worlds.layer_to_y(48),
y_max = mcl_worlds.layer_to_y(61),
})
-- Lava may even appear above surface, but this is very rare
@ -644,8 +644,8 @@ minetest.register_ore({
clust_scarcity = 96000,
clust_num_ores = 1,
clust_size = 1,
y_min = mcl_util.layer_to_y(62),
y_max = mcl_util.layer_to_y(127),
y_min = mcl_worlds.layer_to_y(62),
y_max = mcl_worlds.layer_to_y(127),
})
end
@ -666,7 +666,7 @@ minetest.register_ore({
clust_num_ores = 3,
clust_size = 2,
y_min = mcl_vars.mg_overworld_min,
y_max = mcl_util.layer_to_y(61),
y_max = mcl_worlds.layer_to_y(61),
biomes = { "ExtremeHills", "ExtremeHills_beach", "ExtremeHills_ocean", "ExtremeHills_deep_ocean", "ExtremeHills_underground" },
})
@ -983,7 +983,7 @@ local function register_mgv6_decorations()
--[[ Blue orchid is supposed to appear in swamplands. There are no swamplands in v6.
We emulate swamplands by limiting the height to 5 levels above sea level,
which should be close to the water. ]]
register_mgv6_flower("blue_orchid", 64500, nil, mcl_util.layer_to_y(67))
register_mgv6_flower("blue_orchid", 64500, nil, mcl_worlds.layer_to_y(67))
register_mgv6_flower("oxeye_daisy", 3490)
register_mgv6_flower("poppy", 9439)
@ -1194,7 +1194,7 @@ local function generate_structures(minp, maxp, seed, biomemap)
if math.random(1, fossil_prob) == 1 then
-- Spawn fossil below desert surface between layers 40 and 49
local p1 = {x=p.x, y=math.random(mcl_util.layer_to_y(40), mcl_util.layer_to_y(49)), z=p.z}
local p1 = {x=p.x, y=math.random(mcl_worlds.layer_to_y(40), mcl_worlds.layer_to_y(49)), z=p.z}
-- Very rough check of the environment (we expect to have enough stonelike nodes).
-- Fossils may still appear partially exposed in caves, but this is O.K.
local p2 = vector.add(p1, 4)

@ -1,5 +1,5 @@
mcl_init
mcl_util
mcl_worlds
mcl_core
mcl_loot
mcl_tnt

@ -103,7 +103,7 @@ if mcl_vars.mg_lava then
else
height_min = mcl_vars.mg_bedrock_overworld_max + 2
end
local height_max = mcl_util.layer_to_y(60)
local height_max = mcl_worlds.layer_to_y(60)
-- Chaos Mode: If enabled, rail corridors don't stop generating when hitting obstacles
local chaos_mode = minetest.settings:get_bool("tsm_railcorridors_chaos") or false

@ -1,5 +1,4 @@
mcl_init
mcl_util
mcl_core
mcl_particles
mcl_hunger

@ -1,5 +1,5 @@
mcl_init
mcl_util
mcl_worlds
mcl_core
mcl_particles
mcl_hunger

@ -154,7 +154,7 @@ minetest.register_globalstep(function(dtime)
end
-- Deal Void damage
local void, void_deadly = mcl_util.is_in_void(pos)
local void, void_deadly = mcl_worlds.is_in_void(pos)
if void_deadly then
-- Player is deep into the void, deal void damage
if player:get_hp() > 0 then