From 10a08197908e7033e96cee1e6b3efc2c99d291e4 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 11 Nov 2017 21:14:03 +0100 Subject: [PATCH] Fix hearable rain in Nether and End dimensions --- mods/ENVIRONMENT/weather_pack/rain.lua | 3 ++- mods/ENVIRONMENT/weather_pack/weather_core.lua | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mods/ENVIRONMENT/weather_pack/rain.lua b/mods/ENVIRONMENT/weather_pack/rain.lua index 81b3494a..f3c7a6f5 100644 --- a/mods/ENVIRONMENT/weather_pack/rain.lua +++ b/mods/ENVIRONMENT/weather_pack/rain.lua @@ -45,7 +45,7 @@ rain.add_rain_particles = function(player) rain.last_rp_count = 0 for i=rain.particles_count, 1,-1 do local random_pos_x, random_pos_y, random_pos_z = weather.get_random_pos_by_player_look_dir(player) - if minetest.get_node_light({x=random_pos_x, y=random_pos_y, z=random_pos_z}, 0.5) == 15 then + if weather.is_outdoor({x=random_pos_x, y=random_pos_y, z=random_pos_z}) then rain.last_rp_count = rain.last_rp_count + 1 minetest.add_particle({ pos = {x=random_pos_x, y=random_pos_y, z=random_pos_z}, @@ -159,6 +159,7 @@ rain.make_weather = function() for _, player in ipairs(minetest.get_connected_players()) do if (weather.is_underwater(player) or not mcl_util.has_weather(player:getpos())) then + rain.remove_sound(player) return false end rain.add_player(player) diff --git a/mods/ENVIRONMENT/weather_pack/weather_core.lua b/mods/ENVIRONMENT/weather_pack/weather_core.lua index d7222317..ed555b99 100644 --- a/mods/ENVIRONMENT/weather_pack/weather_core.lua +++ b/mods/ENVIRONMENT/weather_pack/weather_core.lua @@ -38,8 +38,13 @@ weather.get_rand_end_time = function(min_duration, max_duration) end end +-- Returns true if pos is outdoor. +-- Outdoor is defined as any node in the Overworld under open sky. +-- FIXME: Nodes below glass also count as “outdoor”, this should not be the case. weather.is_outdoor = function(pos) - if minetest.get_node_light({x=pos.x, y=pos.y + 1, z=pos.z}, 0.5) == 15 then + local cpos = {x=pos.x, y=pos.y+1, z=pos.z} + local _, dim = mcl_util.y_to_layer(cpos.y) + if minetest.get_node_light(cpos, 0.5) == 15 and dim == "overworld" then return true end return false