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

View file

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

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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