diff --git a/mods/ENVIRONMENT/mcl_weather/description.txt b/mods/ENVIRONMENT/mcl_weather/description.txt index 0cd37d0d8..3f28b271e 100644 --- a/mods/ENVIRONMENT/mcl_weather/description.txt +++ b/mods/ENVIRONMENT/mcl_weather/description.txt @@ -1 +1 @@ -Weather: Rain, snow, thunderstorm. +Weather and sky handling: Rain, snow, thunderstorm, End and Nether ambience diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index ae5f17a13..e1bf5695d 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -4,9 +4,9 @@ mcl_weather.skycolor = { -- To skip update interval force_update = true, - + -- Update interval. - update_interval = 15, + update_interval = 0.5, -- Main sky colors: starts from midnight to midnight. -- Please do not set directly. Use add_layer instead. @@ -69,38 +69,48 @@ mcl_weather.skycolor = { -- Update sky color. If players not specified update sky for all players. update_sky_color = function(players) - local color = mcl_weather.skycolor.current_sky_layer_color() - if (color == nil) then - mcl_weather.skycolor.set_default_sky() - return - end - -- Override day/night ratio as well players = mcl_weather.skycolor.utils.get_players(players) + 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) if dim == "overworld" then - player:set_sky(color, "plain", nil, true) - - local lf = mcl_weather.get_current_light_factor() - if mcl_weather.skycolor.current_layer_name() == "lightning" then - player:override_day_night_ratio(1) - elseif lf then - local w = minetest.get_timeofday() - local light = (w * (lf*2)) - if light > 1 then - light = 1 - (light - 1) - end - - light = (light * lf) + 0.15 - - player:override_day_night_ratio(light) - else + if (color == nil) then + -- No sky layers + player:set_sky(nil, "regular") player:override_day_night_ratio(nil) + else + -- Weather skies + player:set_sky(color, "plain", nil, true) + + local lf = mcl_weather.get_current_light_factor() + if mcl_weather.skycolor.current_layer_name() == "lightning" then + player:override_day_night_ratio(1) + elseif lf then + local w = minetest.get_timeofday() + local light = (w * (lf*2)) + if light > 1 then + light = 1 - (light - 1) + end + + light = (light * lf) + 0.15 + + player:override_day_night_ratio(light) + else + player:override_day_night_ratio(nil) + end end + elseif dim == "end" then + local t = "mcl_playerplus_end_sky.png" + player:set_sky("#000000", "skybox", {t,t,t,t,t,t}, false) + player:override_day_night_ratio(0.5) + elseif dim == "nether" then + player:set_sky("#300808", "plain", nil, false) + player:override_day_night_ratio(nil) + elseif dim == "void" then + player:set_sky("#000000", "plain", nil, false) end - -- Other dimensions are handled in mcl_playerplus end end, @@ -119,11 +129,6 @@ mcl_weather.skycolor = { -- Initialy used only on update_transition_sky_color = function() - if #mcl_weather.skycolor.layer_names == 0 then - mcl_weather.skycolor.set_default_sky() - return - end - local multiplier = 100 local rounded_time = math.floor(mcl_weather.skycolor.transition_timer * multiplier) if rounded_time >= mcl_weather.skycolor.transition_time * multiplier then @@ -143,21 +148,6 @@ mcl_weather.skycolor = { end end, - -- Reset sky color to game default. If players not specified update sky for all players. - -- Could be sometimes useful but not recomended to use in general case as there may be other color layers - -- which needs to preserve. - set_default_sky = function(players) - local players = mcl_weather.skycolor.utils.get_players(players) - for _, player in ipairs(players) do - local pos = player:getpos() - local _, dim = mcl_util.y_to_layer(pos.y) - if dim == "overworld" then - player:set_sky(nil, "regular", nil, true) - player:override_day_night_ratio(nil) - end - end - end, - init_transition = function() -- sadly default sky returns unpredictible colors so transition mode becomes usable only for user defined color layers -- Here '2' means that one color layer existed before new added and transition is posible. @@ -205,7 +195,7 @@ mcl_weather.skycolor = { local players = mcl_weather.skycolor.utils.get_players(nil) for _, player in ipairs(players) do return player:get_sky() - end + end return nil end }, diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 5944b667c..066fdef82 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -153,25 +153,8 @@ minetest.register_globalstep(function(dtime) end end - -- Apply black sky in the Void and deal Void damage + -- Deal Void damage local void, void_deadly = mcl_util.is_in_void(pos) - local _, dim = mcl_util.y_to_layer(pos.y) - -- Set dimension skies. - -- FIXME: Sky handling in MCL2 is held together with lots of duct tape. - -- This only works beause mcl_weather currently does not touch the sky for players below the height used for this check. - -- There should be a real skybox API. - if dim == "void" then - player:set_sky("#000000", "plain", nil, false) - elseif dim == "end" then - local t = "mcl_playerplus_end_sky.png" - player:set_sky("#000000", "skybox", {t,t,t,t,t,t}, false) - player:override_day_night_ratio(0.5) - elseif dim == "nether" then - player:set_sky("#300808", "plain", nil, false) - player:override_day_night_ratio(nil) - else - mcl_weather.skycolor.update_sky_color({player}) - end if void_deadly then -- Player is deep into the void, deal void damage if player:get_hp() > 0 then