From eb5378afec1ddc299d12d9d28cfbb95e6dddc3e9 Mon Sep 17 00:00:00 2001 From: cora Date: Sat, 30 Jul 2022 03:57:40 +0200 Subject: [PATCH 01/10] Rain and snow where appropriate(biome, heat, alt) --- mods/ENVIRONMENT/mcl_weather/rain.lua | 19 ++++-- mods/ENVIRONMENT/mcl_weather/snow.lua | 63 ++++++++++++++++--- mods/ENVIRONMENT/mcl_weather/weather_core.lua | 2 + 3 files changed, 72 insertions(+), 12 deletions(-) diff --git a/mods/ENVIRONMENT/mcl_weather/rain.lua b/mods/ENVIRONMENT/mcl_weather/rain.lua index 717f2fd525..a0df57bf96 100644 --- a/mods/ENVIRONMENT/mcl_weather/rain.lua +++ b/mods/ENVIRONMENT/mcl_weather/rain.lua @@ -41,6 +41,13 @@ local psdef= { local textures = {"weather_pack_rain_raindrop_1.png", "weather_pack_rain_raindrop_2.png"} +function mcl_weather.has_rain(pos) + if mgname == "singlenode" or mgname == "v6" then return true end + local bd = minetest.get_biome_data(pos) + if bd.heat > 90 then return false end + return true +end + function mcl_weather.rain.sound_handler(player) return minetest.sound_play("weather_rain", { to_player = player:get_player_name(), @@ -166,13 +173,17 @@ function mcl_weather.rain.make_weather() for _, player in pairs(get_connected_players()) do local pos=player:get_pos() - if mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(pos) then + if mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(pos) or not mcl_weather.has_rain(pos) then mcl_weather.rain.remove_sound(player) mcl_weather.remove_spawners_player(player) else - mcl_weather.rain.add_player(player) - mcl_weather.rain.add_rain_particles(player) - mcl_weather.rain.update_sound(player) + if mcl_weather.has_snow(pos) then + mcl_weather.snow.add_player(player) + else + mcl_weather.rain.add_player(player) + mcl_weather.rain.add_rain_particles(player) + mcl_weather.rain.update_sound(player) + end end end end diff --git a/mods/ENVIRONMENT/mcl_weather/snow.lua b/mods/ENVIRONMENT/mcl_weather/snow.lua index fc9526d63d..bb489ac8d2 100644 --- a/mods/ENVIRONMENT/mcl_weather/snow.lua +++ b/mods/ENVIRONMENT/mcl_weather/snow.lua @@ -4,6 +4,42 @@ mcl_weather.snow = {} local PARTICLES_COUNT_SNOW = tonumber(minetest.settings:get("mcl_weather_snow_particles")) or 100 mcl_weather.snow.init_done = false +local mgname = minetest.get_mapgen_setting("mg_name") + +local snow_biomes = { + "ColdTaiga_underground", + "IcePlains_underground", + "IcePlainsSpikes_underground", + "MegaTaiga_underground", + "Taiga_underground", + "IcePlains_deep_ocean", + "MegaSpruceTaiga_deep_ocean", + "IcePlainsSpikes_ocean", + "StoneBeach_ocean", + "ColdTaiga_deep_ocean", + "MegaTaiga_ocean", + "StoneBeach_deep_ocean", + "IcePlainsSpikes_deep_ocean", + "ColdTaiga_ocean", + "MegaTaiga_deep_ocean", + "MegaSpruceTaiga_ocean", + "ExtremeHills+_ocean", + "IcePlains_ocean", + "Taiga_ocean", + "Taiga_deep_ocean", + "StoneBeach", + "ColdTaiga_beach_water", + "Taiga_beach", + "ColdTaiga_beach", + "Taiga", + "ExtremeHills+_snowtop", + "MegaSpruceTaiga", + "MegaTaiga", + "ExtremeHills+", + "ColdTaiga", + "IcePlainsSpikes", + "IcePlains", +} local psdef= { amount = PARTICLES_COUNT_SNOW, @@ -25,6 +61,18 @@ local psdef= { glow = 1 } +function mcl_weather.has_snow(pos) + if mgname == "singlenode" or mgname == "v6" then return true end + local bd = minetest.get_biome_data(pos) + local bn = minetest.get_biome_name(bd.biome) + local minheight = -64 + if bn:find("Taiga") then minheight = 100 end + if bn:find("MegaSpruce") then minheight = 140 end + if pos.y < minheight then return false end + if table.indexof(snow_biomes,bn) ~= -1 then return true end + return false +end + function mcl_weather.snow.set_sky_box() mcl_weather.skycolor.add_layer( "weather-pack-snow-sky", @@ -46,9 +94,11 @@ function mcl_weather.snow.clear() mcl_weather.remove_all_spawners() end --- Simple random texture getter -function mcl_weather.snow.get_texture() - return "weather_pack_snow_snowflake"..math.random(1,2)..".png" +function mcl_weather.snow.add_player(player) + for i=1,2 do + psdef.texture="weather_pack_snow_snowflake"..i..".png" + mcl_weather.add_spawner_player(player,"snow"..i,psdef) + end end local timer = 0 @@ -70,13 +120,10 @@ minetest.register_globalstep(function(dtime) end for _, player in pairs(get_connected_players()) do - if mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos()) then + if mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos()) or not mcl_weather.has_snow(player:get_pos()) then mcl_weather.remove_spawners_player(player) else - for i=1,2 do - psdef.texture="weather_pack_snow_snowflake"..i..".png" - mcl_weather.add_spawner_player(player,"snow"..i,psdef) - end + mcl_weather.snow.add_player(player) end end end) diff --git a/mods/ENVIRONMENT/mcl_weather/weather_core.lua b/mods/ENVIRONMENT/mcl_weather/weather_core.lua index f7316bcfbe..32d8db4dff 100644 --- a/mods/ENVIRONMENT/mcl_weather/weather_core.lua +++ b/mods/ENVIRONMENT/mcl_weather/weather_core.lua @@ -54,6 +54,8 @@ function mcl_weather.add_spawner_player(pl,id,ps) particlespawners[name] = {} end if not particlespawners[name][id] then + mcl_weather.remove_spawners_player(pl) + particlespawners[name] = {} ps.playername =name ps.attached = pl particlespawners[name][id]=minetest.add_particlespawner(ps) From 2aaeed77205c648dd2cc2b0c0b0654cf0e14a7d1 Mon Sep 17 00:00:00 2001 From: cora Date: Sat, 30 Jul 2022 04:30:41 +0200 Subject: [PATCH 02/10] Pile up snow while snowing --- mods/ENVIRONMENT/mcl_weather/snow.lua | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mods/ENVIRONMENT/mcl_weather/snow.lua b/mods/ENVIRONMENT/mcl_weather/snow.lua index bb489ac8d2..bdd4b57ae7 100644 --- a/mods/ENVIRONMENT/mcl_weather/snow.lua +++ b/mods/ENVIRONMENT/mcl_weather/snow.lua @@ -67,6 +67,7 @@ function mcl_weather.has_snow(pos) local bn = minetest.get_biome_name(bd.biome) local minheight = -64 if bn:find("Taiga") then minheight = 100 end + if bn:find("ColdTaiga") then minheight = 0 end if bn:find("MegaSpruce") then minheight = 140 end if pos.y < minheight then return false end if table.indexof(snow_biomes,bn) ~= -1 then return true end @@ -143,3 +144,34 @@ if mcl_weather.reg_weathers.snow == nil then } } end + +minetest.register_abm({ + label = "Snow piles up", + nodenames = {"group:opaque","group:leaves","group:snow_cover"}, + neighbors = {"air"}, + interval = 27, + chance = 33, + action = function(pos, node, active_object_count, active_object_count_wider) + if node.name == "mcl_core:snowblock" then return end + local above = vector.offset(pos,0,1,0) + local above_node = minetest.get_node(above) + if above_node.name ~= "air" then return end + if (mcl_weather.state == "rain" or mcl_weather.state == "thunder" or mcl_weather.state == "snow") and mcl_weather.is_outdoor(pos) and mcl_weather.has_snow(pos) then + local nn = nil + if node.name:find("snow") then + local l = node.name:sub(-1) + l = tonumber(l) + if node.name == "mcl_core:snow" then + nn={name = "mcl_core:snow_2"} + elseif l and l < 7 then + nn={name="mcl_core:snow_"..tostring(math.min(8,l + 1))} + elseif l and l >= 7 then + nn={name = "mcl_core:snowblock"} + end + if nn then minetest.set_node(pos,nn) end + else + minetest.set_node(above,{name = "mcl_core:snow"}) + end + end + end +}) From 05a6f09f05229b41ff79b8dedef8d7ecdf751b26 Mon Sep 17 00:00:00 2001 From: cora Date: Sat, 30 Jul 2022 05:37:28 +0200 Subject: [PATCH 03/10] Never rain in deserts --- mods/ENVIRONMENT/mcl_weather/rain.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/ENVIRONMENT/mcl_weather/rain.lua b/mods/ENVIRONMENT/mcl_weather/rain.lua index a0df57bf96..1c2e135cfb 100644 --- a/mods/ENVIRONMENT/mcl_weather/rain.lua +++ b/mods/ENVIRONMENT/mcl_weather/rain.lua @@ -44,7 +44,9 @@ local textures = {"weather_pack_rain_raindrop_1.png", "weather_pack_rain_raindro function mcl_weather.has_rain(pos) if mgname == "singlenode" or mgname == "v6" then return true end local bd = minetest.get_biome_data(pos) - if bd.heat > 90 then return false end + local bn = minetest.get_biome_name(bd.biome) + if not mcl_worlds.has_weather(pos) or bn:find("Desert") or bd.heat > 85 then + return false end return true end @@ -173,7 +175,7 @@ function mcl_weather.rain.make_weather() for _, player in pairs(get_connected_players()) do local pos=player:get_pos() - if mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(pos) or not mcl_weather.has_rain(pos) then + 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) else From 50840f6bdcfdf9ef0c5f9d1a242d0ac1d3a88d6c Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 31 Jul 2022 02:03:28 +0200 Subject: [PATCH 04/10] No nether rain lol --- mods/ENVIRONMENT/mcl_weather/rain.lua | 1 + mods/ENVIRONMENT/mcl_weather/snow.lua | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mods/ENVIRONMENT/mcl_weather/rain.lua b/mods/ENVIRONMENT/mcl_weather/rain.lua index 1c2e135cfb..7356f11afc 100644 --- a/mods/ENVIRONMENT/mcl_weather/rain.lua +++ b/mods/ENVIRONMENT/mcl_weather/rain.lua @@ -42,6 +42,7 @@ local psdef= { local textures = {"weather_pack_rain_raindrop_1.png", "weather_pack_rain_raindrop_2.png"} function mcl_weather.has_rain(pos) + if not mcl_worlds.has_weather(pos) then return false end if mgname == "singlenode" or mgname == "v6" then return true end local bd = minetest.get_biome_data(pos) local bn = minetest.get_biome_name(bd.biome) diff --git a/mods/ENVIRONMENT/mcl_weather/snow.lua b/mods/ENVIRONMENT/mcl_weather/snow.lua index bdd4b57ae7..f94ac06958 100644 --- a/mods/ENVIRONMENT/mcl_weather/snow.lua +++ b/mods/ENVIRONMENT/mcl_weather/snow.lua @@ -62,6 +62,7 @@ local psdef= { } function mcl_weather.has_snow(pos) + if not mcl_worlds.has_weather(pos) then return false end if mgname == "singlenode" or mgname == "v6" then return true end local bd = minetest.get_biome_data(pos) local bn = minetest.get_biome_name(bd.biome) @@ -121,7 +122,7 @@ minetest.register_globalstep(function(dtime) end for _, player in pairs(get_connected_players()) do - if mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos()) or not mcl_weather.has_snow(player:get_pos()) then + if mcl_weather.is_underwater(player) or not mcl_weather.has_snow(player:get_pos()) then mcl_weather.remove_spawners_player(player) else mcl_weather.snow.add_player(player) From bb496db60557f07f9a6c09370158068b2bdff050 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 31 Jul 2022 04:46:06 +0200 Subject: [PATCH 05/10] use _mcl_biome_type for weather --- mods/ENVIRONMENT/mcl_weather/rain.lua | 5 +---- mods/ENVIRONMENT/mcl_weather/snow.lua | 11 +++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/mods/ENVIRONMENT/mcl_weather/rain.lua b/mods/ENVIRONMENT/mcl_weather/rain.lua index 7356f11afc..dd8ff0b747 100644 --- a/mods/ENVIRONMENT/mcl_weather/rain.lua +++ b/mods/ENVIRONMENT/mcl_weather/rain.lua @@ -44,10 +44,7 @@ local textures = {"weather_pack_rain_raindrop_1.png", "weather_pack_rain_raindro function mcl_weather.has_rain(pos) if not mcl_worlds.has_weather(pos) then return false end if mgname == "singlenode" or mgname == "v6" then return true end - local bd = minetest.get_biome_data(pos) - local bn = minetest.get_biome_name(bd.biome) - if not mcl_worlds.has_weather(pos) or bn:find("Desert") or bd.heat > 85 then - return false end + if minetest.registered_biomes[minetest.get_biome_name(minetest.get_biome_data(pos).biome)]._mcl_biome_type == "hot" then return false end return true end diff --git a/mods/ENVIRONMENT/mcl_weather/snow.lua b/mods/ENVIRONMENT/mcl_weather/snow.lua index f94ac06958..6f396857c3 100644 --- a/mods/ENVIRONMENT/mcl_weather/snow.lua +++ b/mods/ENVIRONMENT/mcl_weather/snow.lua @@ -66,12 +66,11 @@ function mcl_weather.has_snow(pos) if mgname == "singlenode" or mgname == "v6" then return true end local bd = minetest.get_biome_data(pos) local bn = minetest.get_biome_name(bd.biome) - local minheight = -64 - if bn:find("Taiga") then minheight = 100 end - if bn:find("ColdTaiga") then minheight = 0 end - if bn:find("MegaSpruce") then minheight = 140 end - if pos.y < minheight then return false end - if table.indexof(snow_biomes,bn) ~= -1 then return true end + if minetest.registered_biomes[bn]._mcl_biome_type == "snowy" then return true end + if minetest.registered_biomes[bn]._mcl_biome_type == "cold" then + if bn == "Taiga" and pos.y > 140 then return true end + if bn == "MegaSpruceTaiga" and pos.y > 100 then return true end + end return false end From cae11f99e4a787ddbce117977636f3a9f0fd9fb1 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 31 Jul 2022 05:11:03 +0200 Subject: [PATCH 06/10] fix wrong mapgen setting var --- mods/ENVIRONMENT/mcl_weather/snow.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENVIRONMENT/mcl_weather/snow.lua b/mods/ENVIRONMENT/mcl_weather/snow.lua index 6f396857c3..ac6dbb6ab3 100644 --- a/mods/ENVIRONMENT/mcl_weather/snow.lua +++ b/mods/ENVIRONMENT/mcl_weather/snow.lua @@ -4,7 +4,7 @@ mcl_weather.snow = {} local PARTICLES_COUNT_SNOW = tonumber(minetest.settings:get("mcl_weather_snow_particles")) or 100 mcl_weather.snow.init_done = false -local mgname = minetest.get_mapgen_setting("mg_name") +local mgname = minetest.get_mapgen_setting("mgname") local snow_biomes = { "ColdTaiga_underground", From 4a6f98636d8238adc4d2dd15531bdba9f23e6264 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 31 Jul 2022 05:24:23 +0200 Subject: [PATCH 07/10] fix crash in mapgen v6 --- mods/ENVIRONMENT/mcl_weather/rain.lua | 3 ++- mods/ENVIRONMENT/mcl_weather/snow.lua | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mods/ENVIRONMENT/mcl_weather/rain.lua b/mods/ENVIRONMENT/mcl_weather/rain.lua index dd8ff0b747..14f9d5dab6 100644 --- a/mods/ENVIRONMENT/mcl_weather/rain.lua +++ b/mods/ENVIRONMENT/mcl_weather/rain.lua @@ -44,7 +44,8 @@ local textures = {"weather_pack_rain_raindrop_1.png", "weather_pack_rain_raindro function mcl_weather.has_rain(pos) if not mcl_worlds.has_weather(pos) then return false end if mgname == "singlenode" or mgname == "v6" then return true end - if minetest.registered_biomes[minetest.get_biome_name(minetest.get_biome_data(pos).biome)]._mcl_biome_type == "hot" then return false end + local bd = minetest.registered_biomes[minetest.get_biome_name(minetest.get_biome_data(pos).biome)] + if bd and bd._mcl_biome_type == "hot" then return false end return true end diff --git a/mods/ENVIRONMENT/mcl_weather/snow.lua b/mods/ENVIRONMENT/mcl_weather/snow.lua index ac6dbb6ab3..57e0eba108 100644 --- a/mods/ENVIRONMENT/mcl_weather/snow.lua +++ b/mods/ENVIRONMENT/mcl_weather/snow.lua @@ -4,7 +4,7 @@ mcl_weather.snow = {} local PARTICLES_COUNT_SNOW = tonumber(minetest.settings:get("mcl_weather_snow_particles")) or 100 mcl_weather.snow.init_done = false -local mgname = minetest.get_mapgen_setting("mgname") +local mgname = minetest.get_mapgen_setting("mg_name") local snow_biomes = { "ColdTaiga_underground", @@ -63,11 +63,11 @@ local psdef= { function mcl_weather.has_snow(pos) if not mcl_worlds.has_weather(pos) then return false end - if mgname == "singlenode" or mgname == "v6" then return true end - local bd = minetest.get_biome_data(pos) - local bn = minetest.get_biome_name(bd.biome) - if minetest.registered_biomes[bn]._mcl_biome_type == "snowy" then return true end - if minetest.registered_biomes[bn]._mcl_biome_type == "cold" then + if mgname == "singlenode" or mgname == "v6" then return false end + local bn = minetest.get_biome_name(minetest.get_biome_data(pos).biome) + local bd = minetest.registered_biomes[bn] + if bd._mcl_biome_type == "snowy" then return true end + if bd._mcl_biome_type == "cold" then if bn == "Taiga" and pos.y > 140 then return true end if bn == "MegaSpruceTaiga" and pos.y > 100 then return true end end From ee3b98c809d22daa13b8906e165bfd129e1b220f Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 31 Jul 2022 15:39:29 +0200 Subject: [PATCH 08/10] 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) From a2b003a195058a04889f6aa937aa581fc2b8ed35 Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 1 Aug 2022 12:46:46 +0200 Subject: [PATCH 09/10] sky slightly overcast on weather in non-weather b. --- mods/ENVIRONMENT/mcl_weather/skycolor.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index 9f6028e2e1..fe65721c5f 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -97,13 +97,31 @@ mcl_weather.skycolor = { 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") or not has_weather then + if (mcl_weather.state == "none") then -- Clear weather 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) + elseif not has_weather then + 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) + player:set_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, + }) + player:set_sun({visible = false, sunrise_visible = false}) + player:set_moon({visible = false}) + player:set_stars({visible = false}) elseif has_weather then -- Weather skies local day_color = mcl_weather.skycolor.get_sky_layer_color(0.5) From 4b5476dbff1f884a69338629c1d3c674c3e4a818 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 2 Aug 2022 11:37:43 +0200 Subject: [PATCH 10/10] fix end sky and void crash --- mods/ENVIRONMENT/mcl_weather/rain.lua | 4 +++- mods/ENVIRONMENT/mcl_weather/skycolor.lua | 2 +- mods/ENVIRONMENT/mcl_weather/snow.lua | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mods/ENVIRONMENT/mcl_weather/rain.lua b/mods/ENVIRONMENT/mcl_weather/rain.lua index e416d76e72..2cf95022e1 100644 --- a/mods/ENVIRONMENT/mcl_weather/rain.lua +++ b/mods/ENVIRONMENT/mcl_weather/rain.lua @@ -177,7 +177,9 @@ 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) + if mcl_worlds.has_weather(pos) then + mcl_weather.set_sky_box_clear(player) + end else if mcl_weather.has_snow(pos) then mcl_weather.rain.remove_sound(player) diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index fe65721c5f..b70702b4c2 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -95,7 +95,7 @@ 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)) + local has_weather = (mcl_worlds.has_weather(pos) and (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 -- Clear weather diff --git a/mods/ENVIRONMENT/mcl_weather/snow.lua b/mods/ENVIRONMENT/mcl_weather/snow.lua index 4afed56915..a756c6e7f4 100644 --- a/mods/ENVIRONMENT/mcl_weather/snow.lua +++ b/mods/ENVIRONMENT/mcl_weather/snow.lua @@ -66,8 +66,8 @@ function mcl_weather.has_snow(pos) if mgname == "singlenode" or mgname == "v6" then return false end local bn = minetest.get_biome_name(minetest.get_biome_data(pos).biome) local bd = minetest.registered_biomes[bn] - if bd._mcl_biome_type == "snowy" then return true end - if bd._mcl_biome_type == "cold" then + if bd and bd._mcl_biome_type == "snowy" then return true end + if bd and bd._mcl_biome_type == "cold" then if bn == "Taiga" and pos.y > 140 then return true end if bn == "MegaSpruceTaiga" and pos.y > 100 then return true end end