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
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
cBlockEntityWithItems(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, int a_ItemGridWidth, int a_ItemGridHeight, cWorld *a_World)
virtual void OnAddToWorld(cWorld &a_World, cChunk &a_Chunk) override
Called when the block entity object is added to a world.
cChestEntity * GetSecondaryChest()
Returns the associated secondary chest, if any.
Definition: ChestEntity.cpp:46
cChestEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
Definition: ChestEntity.cpp:17
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
void OpenNewWindow()
Opens a new chest window where this is the primary chest and any neighbour is the secondary.
cChestEntity * m_Neighbour
Neighbouring chest that links to form a double chest.
Definition: ChestEntity.h:61
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
cChestEntity & GetPrimaryChest()
Returns the associated primary chest.
Definition: ChestEntity.cpp:28
virtual bool UsedBy(cPlayer *a_Player) override
Called when a player uses this entity; should open the UI window.
bool IsBlocked()
Returns true if the chest should not be accessible by players.
Definition: ChestEntity.cpp:95
virtual void OnSlotChanged(cItemGrid *a_Grid, int a_SlotNum) override
cItemGrid::cListener overrides:
int m_NumActivePlayers
Number of players who currently have this chest open.
Definition: ChestEntity.h:58
int GetNumberOfPlayers(void) const
Gets the number of players who currently have this chest open.
Definition: ChestEntity.h:40
virtual void SendTo(cClientHandle &a_Client) override
Sends the packet defining the block entity to the client specified.
void SetNumberOfPlayers(int a_NumActivePlayers)
Sets the number of players who currently have this chest open.
Definition: ChestEntity.h:53
void DestroyWindow()
Forces any players to close the owned window.
Definition: ChestEntity.cpp:82
virtual void OnRemoveFromWorld() override
Called when the block entity object is removed from a world.
Definition: Chunk.h:36
Definition: Player.h:29
Definition: World.h:53