From ee3b98c809d22daa13b8906e165bfd129e1b220f Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 31 Jul 2022 15:39:29 +0200 Subject: [PATCH] Fix skybox in non-weather areas --- mods/ENVIRONMENT/mcl_weather/rain.lua | 4 +++ mods/ENVIRONMENT/mcl_weather/skycolor.lua | 35 +++++++++++++---------- mods/ENVIRONMENT/mcl_weather/snow.lua | 2 ++ 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/mods/ENVIRONMENT/mcl_weather/rain.lua b/mods/ENVIRONMENT/mcl_weather/rain.lua index 14f9d5dab6..e416d76e72 100644 --- a/mods/ENVIRONMENT/mcl_weather/rain.lua +++ b/mods/ENVIRONMENT/mcl_weather/rain.lua @@ -177,13 +177,17 @@ function mcl_weather.rain.make_weather() if mcl_weather.is_underwater(player) or not mcl_weather.has_rain(pos) then mcl_weather.rain.remove_sound(player) mcl_weather.remove_spawners_player(player) + mcl_weather.set_sky_box_clear(player) else if mcl_weather.has_snow(pos) then + mcl_weather.rain.remove_sound(player) mcl_weather.snow.add_player(player) + mcl_weather.snow.set_sky_box() else mcl_weather.rain.add_player(player) mcl_weather.rain.add_rain_particles(player) mcl_weather.rain.update_sound(player) + mcl_weather.rain.set_sky_box() end end end diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index 54751007bd..9f6028e2e1 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -1,6 +1,21 @@ local mods_loaded = false local NIGHT_VISION_RATIO = 0.45 +function mcl_weather.set_sky_box_clear(player) + player:set_sky({ + type = "regular", + sky_color = { + day_sky = "#92B9FF", + day_horizon = "#B4D0FF", + dawn_sky = "#B4BAFA", + dawn_horizon = "#BAC1F0", + night_sky = "#006AFF", + night_horizon = "#4090FF", + }, + clouds = true, + }) +end + mcl_weather.skycolor = { -- Should be activated before do any effect. active = true, @@ -9,7 +24,7 @@ mcl_weather.skycolor = { force_update = true, -- Update interval. - update_interval = 15, + update_interval = 3, -- Main sky colors: starts from midnight to midnight. -- Please do not set directly. Use add_layer instead. @@ -80,26 +95,16 @@ mcl_weather.skycolor = { for _, player in ipairs(players) do local pos = player:get_pos() local dim = mcl_worlds.pos_to_dimension(pos) + local has_weather = ((mcl_weather.state == "snow" or mcl_weather.state =="rain" or mcl_weather.state == "thunder") and mcl_weather.has_snow(pos)) or ((mcl_weather.state =="rain" or mcl_weather.state == "thunder") and mcl_weather.has_rain(pos)) if dim == "overworld" then - if (mcl_weather.state == "none") then + if (mcl_weather.state == "none") or not has_weather then -- Clear weather - player:set_sky({ - type = "regular", - sky_color = { - day_sky = "#92B9FF", - day_horizon = "#B4D0FF", - dawn_sky = "#B4BAFA", - dawn_horizon = "#BAC1F0", - night_sky = "#006AFF", - night_horizon = "#4090FF", - }, - clouds = true, - }) + mcl_weather.set_sky_box_clear(player) player:set_sun({visible = true, sunrise_visible = true}) player:set_moon({visible = true}) player:set_stars({visible = true}) mcl_weather.skycolor.override_day_night_ratio(player, nil) - else + elseif has_weather then -- Weather skies local day_color = mcl_weather.skycolor.get_sky_layer_color(0.5) local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.75) diff --git a/mods/ENVIRONMENT/mcl_weather/snow.lua b/mods/ENVIRONMENT/mcl_weather/snow.lua index 57e0eba108..4afed56915 100644 --- a/mods/ENVIRONMENT/mcl_weather/snow.lua +++ b/mods/ENVIRONMENT/mcl_weather/snow.lua @@ -123,8 +123,10 @@ minetest.register_globalstep(function(dtime) for _, player in pairs(get_connected_players()) do if mcl_weather.is_underwater(player) or not mcl_weather.has_snow(player:get_pos()) then mcl_weather.remove_spawners_player(player) + mcl_weather.set_sky_box_clear(player) else mcl_weather.snow.add_player(player) + mcl_weather.snow.set_sky_box() end end end)