Merge branch 'master' into elytra-overhaul

This commit is contained in:
SumianVoice 2022-08-02 10:27:14 +00:00
commit e28c0d311a
4 changed files with 150 additions and 26 deletions

View file

@ -41,6 +41,14 @@ 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.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
function mcl_weather.rain.sound_handler(player)
return minetest.sound_play("weather_rain", {
to_player = player:get_player_name(),
@ -166,13 +174,23 @@ 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_weather.has_rain(pos) then
mcl_weather.rain.remove_sound(player)
mcl_weather.remove_spawners_player(player)
if mcl_worlds.has_weather(pos) then
mcl_weather.set_sky_box_clear(player)
end
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.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
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,34 @@ 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_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
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 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)
local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.75)

View file

@ -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,19 @@ local psdef= {
glow = 1
}
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 false end
local bn = minetest.get_biome_name(minetest.get_biome_data(pos).biome)
local bd = minetest.registered_biomes[bn]
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
return false
end
function mcl_weather.snow.set_sky_box()
mcl_weather.skycolor.add_layer(
"weather-pack-snow-sky",
@ -46,9 +95,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 +121,12 @@ 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_weather.has_snow(player:get_pos()) then
mcl_weather.remove_spawners_player(player)
mcl_weather.set_sky_box_clear(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)
mcl_weather.snow.set_sky_box()
end
end
end)
@ -96,3 +146,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
})

View file

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