Fix skybox in non-weather areas

This commit is contained in:
cora 2022-07-31 15:39:29 +02:00
parent 4a6f98636d
commit ee3b98c809
3 changed files with 26 additions and 15 deletions

View File

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

View File

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

View File

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