From c7fc3845c193123db105f5fcb30bb3332842e956 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 17 Aug 2017 20:40:55 +0200 Subject: [PATCH] Disable compass+clock updates in Nether, End, Void --- mods/ITEMS/mcl_clock/depends.txt | 3 ++- mods/ITEMS/mcl_clock/init.lua | 14 +++++++++----- mods/ITEMS/mcl_compass/depends.txt | 1 + mods/ITEMS/mcl_compass/init.lua | 26 +++++++++++++++----------- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/mods/ITEMS/mcl_clock/depends.txt b/mods/ITEMS/mcl_clock/depends.txt index 0430af2c8..bf2f4ce73 100644 --- a/mods/ITEMS/mcl_clock/depends.txt +++ b/mods/ITEMS/mcl_clock/depends.txt @@ -1,3 +1,4 @@ -mcl_core +mcl_init +mcl_util mesecons doc? diff --git a/mods/ITEMS/mcl_clock/init.lua b/mods/ITEMS/mcl_clock/init.lua index c011b1ee2..6a40630ce 100644 --- a/mods/ITEMS/mcl_clock/init.lua +++ b/mods/ITEMS/mcl_clock/init.lua @@ -76,11 +76,15 @@ minetest.register_globalstep(function(dtime) local players = minetest.get_connected_players() for p, player in ipairs(players) do for s, stack in ipairs(player:get_inventory():get_list("main")) do - local count = stack:get_count() - if stack:get_name() == mcl_clock.stereotype then - player:get_inventory():set_stack("main", s, "mcl_clock:clock_"..now.." "..count) - elseif string.sub(stack:get_name(), 1, 16) == "mcl_clock:clock_" then - player:get_inventory():set_stack("main", s, "mcl_clock:clock_"..now.." "..count) + local _, dim = mcl_util.y_to_layer(player:getpos().y) + -- Clocks do not work in the End, Nether or the Void + if dim ~= "end" and dim ~= "nether" and dim ~= "void" then + local count = stack:get_count() + if stack:get_name() == mcl_clock.stereotype then + player:get_inventory():set_stack("main", s, "mcl_clock:clock_"..now.." "..count) + elseif string.sub(stack:get_name(), 1, 16) == "mcl_clock:clock_" then + player:get_inventory():set_stack("main", s, "mcl_clock:clock_"..now.." "..count) + end end end end diff --git a/mods/ITEMS/mcl_compass/depends.txt b/mods/ITEMS/mcl_compass/depends.txt index 0430af2c8..53ee1117a 100644 --- a/mods/ITEMS/mcl_compass/depends.txt +++ b/mods/ITEMS/mcl_compass/depends.txt @@ -1,3 +1,4 @@ mcl_core +mcl_util mesecons doc? diff --git a/mods/ITEMS/mcl_compass/init.lua b/mods/ITEMS/mcl_compass/init.lua index b033c2b47..8c230b223 100644 --- a/mods/ITEMS/mcl_compass/init.lua +++ b/mods/ITEMS/mcl_compass/init.lua @@ -26,18 +26,22 @@ minetest.register_globalstep(function(dtime) end end local pos = player:getpos() - local dir = player:get_look_horizontal() - local angle_north = math.deg(math.atan2(spawn.x - pos.x, spawn.z - pos.z)) - if angle_north < 0 then angle_north = angle_north + 360 end - local angle_dir = -math.deg(dir) - local angle_relative = (angle_north - angle_dir + 180) % 360 - local compass_image = math.floor((angle_relative/11.25) + 0.5)%32 + local _, dim = mcl_util.y_to_layer(pos.y) + -- Compasses do not work in the End, Nether or the Void + if dim ~= "end" and dim ~= "nether" and dim ~= "void" then + local dir = player:get_look_horizontal() + local angle_north = math.deg(math.atan2(spawn.x - pos.x, spawn.z - pos.z)) + if angle_north < 0 then angle_north = angle_north + 360 end + local angle_dir = -math.deg(dir) + local angle_relative = (angle_north - angle_dir + 180) % 360 + local compass_image = math.floor((angle_relative/11.25) + 0.5)%32 - for j,stack in ipairs(player:get_inventory():get_list("main")) do - if minetest.get_item_group(stack:get_name(), "compass") ~= 0 and - minetest.get_item_group(stack:get_name(), "compass")-1 ~= compass_image then - local count = stack:get_count() - player:get_inventory():set_stack("main", j, ItemStack("mcl_compass:"..compass_image.." "..count)) + for j,stack in ipairs(player:get_inventory():get_list("main")) do + if minetest.get_item_group(stack:get_name(), "compass") ~= 0 and + minetest.get_item_group(stack:get_name(), "compass")-1 ~= compass_image then + local count = stack:get_count() + player:get_inventory():set_stack("main", j, ItemStack("mcl_compass:"..compass_image.." "..count)) + end end end end