summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockBed.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-02-20 21:33:54 +0100
committerMattes D <github@xoft.cz>2014-02-20 21:33:54 +0100
commiteabf25ddbdb9bc89a1156f959e339d38b9459cd6 (patch)
treed5d3fd5c2d50defc3bced37f9955a2f374bbc48f /src/Blocks/BlockBed.cpp
parentDisabled the leak finder. (diff)
parentBlockBed.cpp: Fixed space at if statement (diff)
downloadcuberite-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 '')
-rw-r--r--src/Blocks/BlockBed.cpp25
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
+
+