From f3319c4d5f0a83069a63442197e79e54fa9d6a21 Mon Sep 17 00:00:00 2001 From: "nielsbreu@gmail.com" Date: Sat, 15 Jun 2013 17:10:34 +0000 Subject: You can only sleep when the time is day, and beds explode if the dimension is not Overworld. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1592 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Blocks/BlockBed.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'source') diff --git a/source/Blocks/BlockBed.cpp b/source/Blocks/BlockBed.cpp index 57af759b8..2ed8c1636 100644 --- a/source/Blocks/BlockBed.cpp +++ b/source/Blocks/BlockBed.cpp @@ -53,19 +53,29 @@ void cBlockBedHandler::OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, void cBlockBedHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) { - NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - if (Meta & 0x8) + if (a_World->GetDimension() != 0) { - // Is pillow - a_World->BroadcastUseBed(*a_Player, a_BlockX, a_BlockY, a_BlockZ); - } - else - { - // Is foot end - Vector3i Direction = MetaDataToDirection( Meta & 0x7 ); - if (a_World->GetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z) == E_BLOCK_BED) // Must always use pillow location for sleeping + a_World->DoExplosiontAt(5, a_BlockX, a_BlockY, a_BlockZ); + } else { + if (a_World->GetTimeOfDay() > 13000) { - a_World->BroadcastUseBed(*a_Player, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z); + NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); + if (Meta & 0x8) + { + // Is pillow + a_World->BroadcastUseBed(*a_Player, a_BlockX, a_BlockY, a_BlockZ); + } + else + { + // Is foot end + Vector3i Direction = MetaDataToDirection( Meta & 0x7 ); + if (a_World->GetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z) == E_BLOCK_BED) // Must always use pillow location for sleeping + { + a_World->BroadcastUseBed(*a_Player, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z); + } + } + } else { + a_Player->SendMessageA("You can only sleep at night"); } } } -- cgit v1.2.3