mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-23 02:51:06 +01:00
Merge branch 'master' into elytra-overhaul
This commit is contained in:
commit
e28c0d311a
4 changed files with 150 additions and 26 deletions
|
@ -41,6 +41,14 @@ local psdef= {
|
||||||
|
|
||||||
local textures = {"weather_pack_rain_raindrop_1.png", "weather_pack_rain_raindrop_2.png"}
|
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)
|
function mcl_weather.rain.sound_handler(player)
|
||||||
return minetest.sound_play("weather_rain", {
|
return minetest.sound_play("weather_rain", {
|
||||||
to_player = player:get_player_name(),
|
to_player = player:get_player_name(),
|
||||||
|
@ -166,13 +174,23 @@ function mcl_weather.rain.make_weather()
|
||||||
|
|
||||||
for _, player in pairs(get_connected_players()) do
|
for _, player in pairs(get_connected_players()) do
|
||||||
local pos=player:get_pos()
|
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.rain.remove_sound(player)
|
||||||
mcl_weather.remove_spawners_player(player)
|
mcl_weather.remove_spawners_player(player)
|
||||||
|
if mcl_worlds.has_weather(pos) then
|
||||||
|
mcl_weather.set_sky_box_clear(player)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
mcl_weather.rain.add_player(player)
|
if mcl_weather.has_snow(pos) then
|
||||||
mcl_weather.rain.add_rain_particles(player)
|
mcl_weather.rain.remove_sound(player)
|
||||||
mcl_weather.rain.update_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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,21 @@
|
||||||
local mods_loaded = false
|
local mods_loaded = false
|
||||||
local NIGHT_VISION_RATIO = 0.45
|
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 = {
|
mcl_weather.skycolor = {
|
||||||
-- Should be activated before do any effect.
|
-- Should be activated before do any effect.
|
||||||
active = true,
|
active = true,
|
||||||
|
@ -9,7 +24,7 @@ mcl_weather.skycolor = {
|
||||||
force_update = true,
|
force_update = true,
|
||||||
|
|
||||||
-- Update interval.
|
-- Update interval.
|
||||||
update_interval = 15,
|
update_interval = 3,
|
||||||
|
|
||||||
-- Main sky colors: starts from midnight to midnight.
|
-- Main sky colors: starts from midnight to midnight.
|
||||||
-- Please do not set directly. Use add_layer instead.
|
-- Please do not set directly. Use add_layer instead.
|
||||||
|
@ -80,26 +95,34 @@ mcl_weather.skycolor = {
|
||||||
for _, player in ipairs(players) do
|
for _, player in ipairs(players) do
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
local dim = mcl_worlds.pos_to_dimension(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 dim == "overworld" then
|
||||||
if (mcl_weather.state == "none") then
|
if (mcl_weather.state == "none") then
|
||||||
-- Clear weather
|
-- Clear weather
|
||||||
player:set_sky({
|
mcl_weather.set_sky_box_clear(player)
|
||||||
type = "regular",
|
|
||||||
sky_color = {
|
|
||||||
day_sky = "#92B9FF",
|
|
||||||
day_horizon = "#B4D0FF",
|
|
||||||
dawn_sky = "#B4BAFA",
|
|
||||||
dawn_horizon = "#BAC1F0",
|
|
||||||
night_sky = "#006AFF",
|
|
||||||
night_horizon = "#4090FF",
|
|
||||||
},
|
|
||||||
clouds = true,
|
|
||||||
})
|
|
||||||
player:set_sun({visible = true, sunrise_visible = true})
|
player:set_sun({visible = true, sunrise_visible = true})
|
||||||
player:set_moon({visible = true})
|
player:set_moon({visible = true})
|
||||||
player:set_stars({visible = true})
|
player:set_stars({visible = true})
|
||||||
mcl_weather.skycolor.override_day_night_ratio(player, nil)
|
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
|
-- Weather skies
|
||||||
local day_color = mcl_weather.skycolor.get_sky_layer_color(0.5)
|
local day_color = mcl_weather.skycolor.get_sky_layer_color(0.5)
|
||||||
local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.75)
|
local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.75)
|
||||||
|
|
|
@ -4,6 +4,42 @@ mcl_weather.snow = {}
|
||||||
|
|
||||||
local PARTICLES_COUNT_SNOW = tonumber(minetest.settings:get("mcl_weather_snow_particles")) or 100
|
local PARTICLES_COUNT_SNOW = tonumber(minetest.settings:get("mcl_weather_snow_particles")) or 100
|
||||||
mcl_weather.snow.init_done = false
|
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= {
|
local psdef= {
|
||||||
amount = PARTICLES_COUNT_SNOW,
|
amount = PARTICLES_COUNT_SNOW,
|
||||||
|
@ -25,6 +61,19 @@ local psdef= {
|
||||||
glow = 1
|
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()
|
function mcl_weather.snow.set_sky_box()
|
||||||
mcl_weather.skycolor.add_layer(
|
mcl_weather.skycolor.add_layer(
|
||||||
"weather-pack-snow-sky",
|
"weather-pack-snow-sky",
|
||||||
|
@ -46,9 +95,11 @@ function mcl_weather.snow.clear()
|
||||||
mcl_weather.remove_all_spawners()
|
mcl_weather.remove_all_spawners()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Simple random texture getter
|
function mcl_weather.snow.add_player(player)
|
||||||
function mcl_weather.snow.get_texture()
|
for i=1,2 do
|
||||||
return "weather_pack_snow_snowflake"..math.random(1,2)..".png"
|
psdef.texture="weather_pack_snow_snowflake"..i..".png"
|
||||||
|
mcl_weather.add_spawner_player(player,"snow"..i,psdef)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local timer = 0
|
local timer = 0
|
||||||
|
@ -70,13 +121,12 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, player in pairs(get_connected_players()) do
|
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.remove_spawners_player(player)
|
||||||
|
mcl_weather.set_sky_box_clear(player)
|
||||||
else
|
else
|
||||||
for i=1,2 do
|
mcl_weather.snow.add_player(player)
|
||||||
psdef.texture="weather_pack_snow_snowflake"..i..".png"
|
mcl_weather.snow.set_sky_box()
|
||||||
mcl_weather.add_spawner_player(player,"snow"..i,psdef)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -96,3 +146,34 @@ if mcl_weather.reg_weathers.snow == nil then
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
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
|
||||||
|
})
|
||||||
|
|
|
@ -54,6 +54,8 @@ function mcl_weather.add_spawner_player(pl,id,ps)
|
||||||
particlespawners[name] = {}
|
particlespawners[name] = {}
|
||||||
end
|
end
|
||||||
if not particlespawners[name][id] then
|
if not particlespawners[name][id] then
|
||||||
|
mcl_weather.remove_spawners_player(pl)
|
||||||
|
particlespawners[name] = {}
|
||||||
ps.playername =name
|
ps.playername =name
|
||||||
ps.attached = pl
|
ps.attached = pl
|
||||||
particlespawners[name][id]=minetest.add_particlespawner(ps)
|
particlespawners[name][id]=minetest.add_particlespawner(ps)
|
||||||
|
|
Loading…
Reference in a new issue