From c9dc4055314e7b6fe47a58f6fc3aadbeaa050c3c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 8 Jan 2018 03:19:19 +0100 Subject: [PATCH] Beds: First check distance --- mods/ITEMS/mcl_beds/functions.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index 6d79bc001..42f283f51 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -65,6 +65,12 @@ local function lay_down(player, pos, bed_pos, state, skip) end if bed_pos then + -- No sleeping if too far away + if vector.distance(bed_pos, pos) > 2 then + minetest.chat_send_player(name, "You can't sleep, the bed's too far away!") + return + end + -- No sleeping if monsters nearby. -- The exceptions above apply. -- Zombie pigmen only prevent sleep while they are hostle. @@ -83,12 +89,6 @@ local function lay_down(player, pos, bed_pos, state, skip) end end end - - -- No sleeping if too far away - if vector.distance(bed_pos, pos) > 2 then - minetest.chat_send_player(name, "You can't sleep, the bed's too far away!") - return - end end -- stand up