diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 95b9f7f6ce..e2357b8d99 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -388,6 +388,28 @@ function mcl_util.layer_to_y(layer, mc_dimension) end end +-- Takes a position and returns true if this position can have weather +function mcl_util.has_weather(pos) + -- Weather in the Overworld and the high part of the void below + return pos.y <= mcl_vars.mg_overworld_max and pos.y >= mcl_vars.mg_overworld_min - 64 +end + +-- Takes a position (pos) and returns true if compasses are working here +function mcl_util.compass_works(pos) + -- It doesn't work in Nether and the End, but it works in the Overworld and in the high part of the void below + local _, dim = mcl_util.y_to_layer(pos.y) + if dim ~= "nether" or dim ~= "end" then + return false + elseif dim == "void" then + return pos.y <= mcl_vars.mg_overworld_max and pos.y >= mcl_vars.mg_overworld_min - 64 + else + return true + end +end + +-- Takes a position (pos) and returns true if clocks are working here +mcl_util.clock_works = mcl_util.compass_works + -- Returns a on_place function for plants -- * condition: function(pos, node) -- * A function which is called by the on_place function to check if the node can be placed diff --git a/mods/ENVIRONMENT/weather_pack/rain.lua b/mods/ENVIRONMENT/weather_pack/rain.lua index 18ed060565..60b6acfc32 100644 --- a/mods/ENVIRONMENT/weather_pack/rain.lua +++ b/mods/ENVIRONMENT/weather_pack/rain.lua @@ -1,21 +1,21 @@ rain = { - -- max rain particles created at time + -- max rain particles created at time particles_count = 35, - -- flag to turn on/off extinguish fire for rain + -- flag to turn on/off extinguish fire for rain extinguish_fire = true, - + -- flag useful when mixing weathers raining = false, - -- keeping last timeofday value (rounded). + -- keeping last timeofday value (rounded). -- Defaulted to non-existing value for initial comparing. sky_last_update = -1, init_done = false, } -rain.sound_handler = function(player) +rain.sound_handler = function(player) return minetest.sound_play("weather_rain", { object = player, max_hear_distance = 2, @@ -77,7 +77,7 @@ rain.get_texture = function() return texture_name; end --- register player for rain weather. +-- register player for rain weather. -- basically needs for origin sky reference and rain sound controls. rain.add_player = function(player) if weather.players[player:get_player_name()] == nil then @@ -99,7 +99,7 @@ rain.remove_player = function(player) end -- adds and removes rain sound depending how much rain particles around player currently exist. --- have few seconds delay before each check to avoid on/off sound too often +-- have few seconds delay before each check to avoid on/off sound too often -- when player stay on 'edge' where sound should play and stop depending from random raindrop appearance. rain.update_sound = function(player) local player_meta = weather.players[player:get_player_name()] @@ -107,16 +107,16 @@ rain.update_sound = function(player) if player_meta.sound_updated ~= nil and player_meta.sound_updated + 5 > os.time() then return false end - + if player_meta.sound_handler ~= nil then if rain.last_rp_count == 0 then minetest.sound_stop(player_meta.sound_handler) player_meta.sound_handler = nil end elseif rain.last_rp_count > 0 then - player_meta.sound_handler = rain.sound_handler(player) + player_meta.sound_handler = rain.sound_handler(player) end - + player_meta.sound_updated = os.time() end end @@ -131,7 +131,7 @@ rain.remove_sound = function(player) end -- callback function for removing rain -rain.clear = function() +rain.clear = function() rain.raining = false rain.sky_last_update = -1 rain.init_done = false @@ -143,10 +143,10 @@ rain.clear = function() end minetest.register_globalstep(function(dtime) - if weather.state ~= "rain" then + if weather.state ~= "rain" then return false end - + rain.make_weather() end) @@ -158,7 +158,7 @@ rain.make_weather = function() end for _, player in ipairs(minetest.get_connected_players()) do - if (weather.is_underwater(player)) then + if (weather.is_underwater(player) or not mcl_util.has_weather(player:getpos())) then return false end rain.add_player(player) diff --git a/mods/ENVIRONMENT/weather_pack/snow.lua b/mods/ENVIRONMENT/weather_pack/snow.lua index 7b4ec19d1b..2ab2716d46 100644 --- a/mods/ENVIRONMENT/weather_pack/snow.lua +++ b/mods/ENVIRONMENT/weather_pack/snow.lua @@ -73,7 +73,7 @@ minetest.register_globalstep(function(dtime) end for _, player in ipairs(minetest.get_connected_players()) do - if (weather.is_underwater(player)) then + if (weather.is_underwater(player) or not mcl_util.has_weather(player:getpos())) then return false end snow.add_rain_particles(player) diff --git a/mods/ITEMS/mcl_clock/init.lua b/mods/ITEMS/mcl_clock/init.lua index 48bced1750..d2660b4b2d 100644 --- a/mods/ITEMS/mcl_clock/init.lua +++ b/mods/ITEMS/mcl_clock/init.lua @@ -91,8 +91,8 @@ minetest.register_globalstep(function(dtime) for s, stack in ipairs(player:get_inventory():get_list("main")) do local _, dim = mcl_util.y_to_layer(player:getpos().y) local frame - -- Clocks do not work in the End, Nether or the Void - if dim == "end" or dim == "nether" or dim == "void" then + -- Clocks do not work in certain zones + if not mcl_util.clock_works(player:getpos()) then frame = random_frame else frame = now diff --git a/mods/ITEMS/mcl_compass/init.lua b/mods/ITEMS/mcl_compass/init.lua index ff9db2aebf..03edca0163 100644 --- a/mods/ITEMS/mcl_compass/init.lua +++ b/mods/ITEMS/mcl_compass/init.lua @@ -31,8 +31,8 @@ minetest.register_globalstep(function(dtime) local pos = player:getpos() local _, dim = mcl_util.y_to_layer(pos.y) local compass_image - -- Compasses do not work in the End, Nether or the Void - if dim == "end" or dim == "nether" or dim == "void" then + -- Compasses do not work in certain zones + if not mcl_util.compass_works(player:getpos()) then compass_image = random_frame else local spawn = {x=0,y=0,z=0}