From 09307292bce5145a8eec8837de636a448c9f0672 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Wed, 26 Jun 2024 19:51:33 -0500 Subject: [PATCH] Make sure overworld always gets a sky update regardless of weather, add assert to enforce sky color gets set every update --- mods/ENVIRONMENT/mcl_weather/skycolor.lua | 4 +- .../mcl_weather/skycolor/dimensions.lua | 44 +++++++++---------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index 9beb82b64..19cec9eac 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -155,7 +155,9 @@ function skycolor.update_player_sky_color(player) skycolor_filters[i](player, sky_data) end - if sky_data.sky then player:set_sky(sky_data.sky) end + assert(sky_data.sky) + player:set_sky(sky_data.sky) + if sky_data.sun then player:set_sun(sky_data.sun) end if sky_data.moon then player:set_moon(sky_data.moon) end if sky_data.stars then player:set_stars(sky_data.stars) end diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor/dimensions.lua b/mods/ENVIRONMENT/mcl_weather/skycolor/dimensions.lua index 16ae0a1d2..fcf85a7e0 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor/dimensions.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor/dimensions.lua @@ -39,12 +39,29 @@ function dimension_handlers.overworld(player, sky_data) end end + -- Use overworld defaults + local day_color = mcl_weather.skycolor.get_sky_layer_color(0.15) + local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.27) + local night_color = mcl_weather.skycolor.get_sky_layer_color(0.1) + sky_data.sky = { + type = "regular", + sky_color = { + day_sky = day_color, + day_horizon = day_color, + dawn_sky = dawn_color, + dawn_horizon = dawn_color, + night_sky = night_color, + night_horizon = night_color, + }, + clouds = true, + } + sky_data.sun = {visible = true, sunrise_visible = true} + sky_data.moon = {visible = true} + sky_data.stars = {visible = true} + if mcl_weather.state == "none" then -- Clear weather mcl_weather.set_sky_box_clear(player,biomesky,biomefog) - sky_data.sun = {visible = true, sunrise_visible = true} - sky_data.moon = {visible = true} - sky_data.stars = {visible = true} return end @@ -83,28 +100,7 @@ function dimension_handlers.overworld(player, sky_data) local new_light = math.max(light_factor * light_multiplier, MINIMUM_LIGHT_LEVEL) sky_data.day_night_ratio = new_light end - return end - - -- No weather that affects the sky color, use default values - local day_color = mcl_weather.skycolor.get_sky_layer_color(0.15) - local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.27) - local night_color = mcl_weather.skycolor.get_sky_layer_color(0.1) - sky_data.sky = { - type = "regular", - sky_color = { - day_sky = day_color, - day_horizon = day_color, - dawn_sky = dawn_color, - dawn_horizon = dawn_color, - night_sky = night_color, - night_horizon = night_color, - }, - clouds = true, - } - sky_data.sun = {visible = false, sunrise_visible = false} - sky_data.moon = {visible = false} - sky_data.stars = {visible = false} end -- This can't be function dimension_handlers.end() due to lua syntax