summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockBed.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2015-02-08 22:21:48 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2015-02-08 22:21:48 +0100
commit3869f76cc23c6ed1df1ad4f6de9c2561f95e08f0 (patch)
tree263dd59173d388fa8e7c83d51c928004a230737a /src/Blocks/BlockBed.h
parentProtocol 1.7: Fixed Coverity issues. (diff)
downloadcuberite-3869f76cc23c6ed1df1ad4f6de9c2561f95e08f0.tar
cuberite-3869f76cc23c6ed1df1ad4f6de9c2561f95e08f0.tar.gz
cuberite-3869f76cc23c6ed1df1ad4f6de9c2561f95e08f0.tar.bz2
cuberite-3869f76cc23c6ed1df1ad4f6de9c2561f95e08f0.tar.lz
cuberite-3869f76cc23c6ed1df1ad4f6de9c2561f95e08f0.tar.xz
cuberite-3869f76cc23c6ed1df1ad4f6de9c2561f95e08f0.tar.zst
cuberite-3869f76cc23c6ed1df1ad4f6de9c2561f95e08f0.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockBed.h25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h
index 5b746110a..46f361686 100644
--- a/src/Blocks/BlockBed.h
+++ b/src/Blocks/BlockBed.h
@@ -4,9 +4,9 @@
#include "BlockHandler.h"
#include "MetaRotator.h"
#include "Item.h"
+#include "ChunkInterface.h"
-class cChunkInterface;
class cPlayer;
class cWorldInterface;
@@ -21,17 +21,14 @@ public:
: cMetaRotator<cBlockHandler, 0x3, 0x02, 0x03, 0x00, 0x01, true>(a_BlockType)
{
}
-
-
+
virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
-
virtual bool IsUseable(void) override
{
return true;
}
-
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
@@ -39,14 +36,12 @@ public:
a_Pickups.push_back(cItem(E_ITEM_BED, 1, 0));
}
-
virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override
{
return true;
}
-
// Bed specific helper functions
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
@@ -61,7 +56,6 @@ public:
return ((char)a_Rotation + 2) % 4;
}
-
static Vector3i MetaDataToDirection(NIBBLETYPE a_MetaData)
{
switch (a_MetaData)
@@ -73,6 +67,21 @@ public:
}
return Vector3i();
}
+
+ static void SetBedOccupationState(cChunkInterface & a_ChunkInterface, const Vector3i & a_BedPosition, bool a_IsOccupied)
+ {
+ auto Meta = a_ChunkInterface.GetBlockMeta(a_BedPosition.x, a_BedPosition.y, a_BedPosition.z);
+ if (a_IsOccupied)
+ {
+ Meta |= 0x04; // Where 0x4 = occupied bit
+ }
+ else
+ {
+ Meta &= 0x0b; // Clear the "occupied" bit of the bed's block
+ }
+
+ a_ChunkInterface.SetBlockMeta(a_BedPosition.x, a_BedPosition.y, a_BedPosition.z, Meta);
+ }
} ;