Cuberite
A lightweight, fast and extensible game server for Minecraft
BedEntity.cpp
Go to the documentation of this file.
1 
2 // BedEntity.cpp
3 
4 #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
5 
6 #include "BedEntity.h"
7 #include "../World.h"
8 #include "../Entities/Player.h"
9 #include "../ClientHandle.h"
10 #include "../Blocks/BlockBed.h"
11 
12 
13 
14 
15 
16 cBedEntity::cBedEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World, short a_Color):
17  Super(a_BlockType, a_BlockMeta, a_Pos, a_World),
18  m_Color(a_Color)
19 {
20  ASSERT(a_BlockType == E_BLOCK_BED);
21 }
22 
23 
24 
25 
26 
28 {
29  return cItem(E_ITEM_BED, 1, m_Color);
30 }
31 
32 
33 
34 
35 
37 {
38  Super::CopyFrom(a_Src);
39  auto & src = static_cast<const cBedEntity &>(a_Src);
40  m_Color = src.m_Color;
41 }
42 
43 
44 
45 
46 
48 {
49  a_Client.SendUpdateBlockEntity(*this);
50 }
51 
52 
53 
54 
55 
56 void cBedEntity::SetColor(short a_Color)
57 {
58  m_Color = a_Color;
59 }
@ E_BLOCK_BED
Definition: BlockType.h:36
@ E_ITEM_BED
Definition: BlockType.h:400
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
#define ASSERT(x)
Definition: Globals.h:276
void SetColor(short a_Color)
Set the color of the bed.
Definition: BedEntity.cpp:56
short m_Color
Definition: BedEntity.h:46
virtual cItems ConvertToPickups() const override
Returns the contents of this block entity that it would drop if broken.
Definition: BedEntity.cpp:27
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
Definition: BedEntity.cpp:36
virtual void SendTo(cClientHandle &a_Client) override
Sends the packet defining the block entity to the client specified.
Definition: BedEntity.cpp:47
cBedEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World, short a_Color=E_META_WOOL_RED)
Definition: BedEntity.cpp:16
virtual void CopyFrom(const cBlockEntity &a_Src)
Copies all properties of a_Src into this entity, except for its m_World and location.
Definition: BlockEntity.cpp:66
void SendUpdateBlockEntity(cBlockEntity &a_BlockEntity)
Definition: Item.h:37
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:215
Definition: World.h:53