Cuberite
A lightweight, fast and extensible game server for Minecraft
ChestEntity.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockEntityWithItems.h"
5 #include "../Simulator/RedstoneSimulator.h"
6 
7 
8 
9 
10 
11 class cClientHandle;
12 
13 
14 
15 
16 
17 // tolua_begin
18 class cChestEntity :
20 {
21  // tolua_end
22 
24 
25  // tolua_begin
26 
27 public:
28 
29  enum
30  {
33  } ;
34 
35  // tolua_end
36 
37  cChestEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World);
38 
40  int GetNumberOfPlayers(void) const { return m_NumActivePlayers; }
41 
44 
47 
50  bool ScanNeighbour(cChunk & a_Chunk, Vector3i a_Position);
51 
53  void SetNumberOfPlayers(int a_NumActivePlayers) { m_NumActivePlayers = a_NumActivePlayers; }
54 
55 private:
56 
59 
62 
64  void DestroyWindow();
65 
67  bool IsBlocked();
68 
70  void OpenNewWindow();
71 
72  // cBlockEntity overrides:
73  virtual void CopyFrom(const cBlockEntity & a_Src) override;
74  virtual void OnAddToWorld(cWorld & a_World, cChunk & a_Chunk) override;
75  virtual void OnRemoveFromWorld() override;
76  virtual void SendTo(cClientHandle & a_Client) override;
77  virtual bool UsedBy(cPlayer * a_Player) override;
78 
80  virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) override;
81 } ; // tolua_export
cClientHandle
Definition: ClientHandle.h:49
cChestEntity::cChestEntity
cChestEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
Definition: ChestEntity.cpp:17
cChestEntity::m_Neighbour
cChestEntity * m_Neighbour
Neighbouring chest that links to form a double chest.
Definition: ChestEntity.h:61
cChestEntity::DestroyWindow
void DestroyWindow()
Forces any players to close the owned window.
Definition: ChestEntity.cpp:82
cChestEntity::ScanNeighbour
bool ScanNeighbour(cChunk &a_Chunk, Vector3i a_Position)
Search the given horizontally adjacent relative position for a neighbouring chest of the same type.
Definition: ChestEntity.cpp:56
BlockEntityWithItems.h
cChestEntity::OnRemoveFromWorld
virtual void OnRemoveFromWorld() override
Called when the block entity object is removed from a world.
Definition: ChestEntity.cpp:167
cChestEntity::GetPrimaryChest
cChestEntity & GetPrimaryChest()
Returns the associated primary chest.
Definition: ChestEntity.cpp:28
cChestEntity::OpenNewWindow
void OpenNewWindow()
Opens a new chest window where this is the primary chest and any neighbour is the secondary.
Definition: ChestEntity.cpp:110
cChestEntity::GetSecondaryChest
cChestEntity * GetSecondaryChest()
Returns the associated secondary chest, if any.
Definition: ChestEntity.cpp:46
NIBBLETYPE
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
cChestEntity::GetNumberOfPlayers
int GetNumberOfPlayers(void) const
Gets the number of players who currently have this chest open.
Definition: ChestEntity.h:40
cChestEntity::UsedBy
virtual bool UsedBy(cPlayer *a_Player) override
Called when a player uses this entity; should open the UI window.
Definition: ChestEntity.cpp:192
cWorld
Definition: World.h:47
cBlockEntityWithItems
Definition: BlockEntityWithItems.h:22
cChestEntity::OnAddToWorld
virtual void OnAddToWorld(cWorld &a_World, cChunk &a_Chunk) override
Called when the block entity object is added to a world.
Definition: ChestEntity.cpp:144
cChestEntity::ContentsHeight
@ ContentsHeight
Definition: ChestEntity.h:31
cChestEntity::IsBlocked
bool IsBlocked()
Returns true if the chest should not be accessible by players.
Definition: ChestEntity.cpp:95
cChestEntity::CopyFrom
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: ChestEntity.cpp:129
BLOCKTYPE
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
cChestEntity
Definition: ChestEntity.h:18
cChunk
Definition: Chunk.h:35
cPlayer
Definition: Player.h:27
cItemGrid
Definition: ItemGrid.h:19
cChestEntity::SetNumberOfPlayers
void SetNumberOfPlayers(int a_NumActivePlayers)
Sets the number of players who currently have this chest open.
Definition: ChestEntity.h:53
cChestEntity::OnSlotChanged
virtual void OnSlotChanged(cItemGrid *a_Grid, int a_SlotNum) override
cItemGrid::cListener overrides:
Definition: ChestEntity.cpp:240
cBlockEntityWithItems::cBlockEntityWithItems
cBlockEntityWithItems(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, int a_ItemGridWidth, int a_ItemGridHeight, cWorld *a_World)
Definition: BlockEntityWithItems.cpp:11
cChestEntity::ContentsWidth
@ ContentsWidth
Definition: ChestEntity.h:32
Vector3
Definition: Vector3.h:10
cChestEntity::m_NumActivePlayers
int m_NumActivePlayers
Number of players who currently have this chest open.
Definition: ChestEntity.h:58
cBlockEntity
Definition: BlockEntity.h:24
cChestEntity::SendTo
virtual void SendTo(cClientHandle &a_Client) override
Sends the packet defining the block entity to the client specified.
Definition: ChestEntity.cpp:183