summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockBed.cpp
diff options
context:
space:
mode:
authorTheJumper <maximilian.springer@web.de>2014-02-20 16:26:50 +0100
committerTheJumper <maximilian.springer@web.de>2014-02-20 16:26:50 +0100
commitc2277c6feeae4551c511588e6da8b05e1bc0c22e (patch)
tree449ae418e1ccde50fb30f41a6bdc9661f177bd38 /src/Blocks/BlockBed.cpp
parentAPIDump: Fixed cBlockArea:GetRelBlockType() return types. (diff)
downloadcuberite-c2277c6feeae4551c511588e6da8b05e1bc0c22e.tar
cuberite-c2277c6feeae4551c511588e6da8b05e1bc0c22e.tar.gz
cuberite-c2277c6feeae4551c511588e6da8b05e1bc0c22e.tar.bz2
cuberite-c2277c6feeae4551c511588e6da8b05e1bc0c22e.tar.lz
cuberite-c2277c6feeae4551c511588e6da8b05e1bc0c22e.tar.xz
cuberite-c2277c6feeae4551c511588e6da8b05e1bc0c22e.tar.zst
cuberite-c2277c6feeae4551c511588e6da8b05e1bc0c22e.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..2fa3a7264 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
+
+