From f4ac6335eb9887f72c2c254c87dea352f6d82ed6 Mon Sep 17 00:00:00 2001 From: PrairieWind Date: Fri, 2 Sep 2022 12:37:30 -0600 Subject: [PATCH] Fixed Bed Check Checks time before distance --- mods/ITEMS/mcl_beds/functions.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index e570bd8eb2..464c4ae45c 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -79,6 +79,13 @@ local function lay_down(player, pos, bed_pos, state, skip) awards.unlock(player:get_player_name(), "mcl:sweetDreams") end + -- Check day of time and weather + local tod = minetest.get_timeofday() * 24000 + -- Values taken from Minecraft Wiki with offset of +6000 + if tod < 18541 and tod > 5458 and (not weather_mod or (mcl_weather.get_weather() ~= "thunder")) then + return false, S("You can only sleep at night or during a thunderstorm.") + end + -- No sleeping if too far away if vector.distance(bed_pos, pos) > 2 and vector.distance(bed_pos2, pos) > 2 then return false, S("You can't sleep, the bed's too far away!") @@ -158,13 +165,6 @@ local function lay_down(player, pos, bed_pos, state, skip) return false, S("It's too dangerous to sleep here!") end - -- Check day of time and weather - local tod = minetest.get_timeofday() * 24000 - -- Values taken from Minecraft Wiki with offset of +6000 - if tod < 18541 and tod > 5458 and (not weather_mod or (mcl_weather.get_weather() ~= "thunder")) then - return false, S("You can only sleep at night or during a thunderstorm.") - end - mcl_beds.player[name] = 1 mcl_beds.pos[name] = pos mcl_beds.bed_pos[name] = bed_pos2