diff options
author | Mattes D <github@xoft.cz> | 2014-02-20 21:33:54 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-02-20 21:33:54 +0100 |
commit | eabf25ddbdb9bc89a1156f959e339d38b9459cd6 (patch) | |
tree | d5d3fd5c2d50defc3bced37f9955a2f374bbc48f /src/Blocks/BlockBed.cpp | |
parent | Disabled the leak finder. (diff) | |
parent | BlockBed.cpp: Fixed space at if statement (diff) | |
download | cuberite-eabf25ddbdb9bc89a1156f959e339d38b9459cd6.tar cuberite-eabf25ddbdb9bc89a1156f959e339d38b9459cd6.tar.gz cuberite-eabf25ddbdb9bc89a1156f959e339d38b9459cd6.tar.bz2 cuberite-eabf25ddbdb9bc89a1156f959e339d38b9459cd6.tar.lz cuberite-eabf25ddbdb9bc89a1156f959e339d38b9459cd6.tar.xz cuberite-eabf25ddbdb9bc89a1156f959e339d38b9459cd6.tar.zst cuberite-eabf25ddbdb9bc89a1156f959e339d38b9459cd6.zip |
Diffstat (limited to 'src/Blocks/BlockBed.cpp')
-rw-r--r-- | src/Blocks/BlockBed.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index a6f3c36b6..3dad4feba 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -63,20 +63,29 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface if (a_WorldInterface.GetTimeOfDay() > 13000) { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - if (Meta & 0x8) + if (Meta & 0x4) { - // Is pillow - a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX, a_BlockY, a_BlockZ); + a_Player->SendMessageFailure("This bed is occupied."); } else { - // Is foot end - Vector3i Direction = MetaDataToDirection( Meta & 0x7 ); - if (a_ChunkInterface.GetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z) == E_BLOCK_BED) // Must always use pillow location for sleeping + if (Meta & 0x8) { - a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z); + // Is pillow + a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX, a_BlockY, a_BlockZ); } + else + { + // Is foot end + Vector3i Direction = MetaDataToDirection( Meta & 0x7 ); + if (a_ChunkInterface.GetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z) == E_BLOCK_BED) // Must always use pillow location for sleeping + { + a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z); + } + } + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, (Meta | (1 << 2))); } + } else { a_Player->SendMessageFailure("You can only sleep at night"); } @@ -86,3 +95,5 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface + + |