Cuberite
A lightweight, fast and extensible game server for Minecraft
DropSpenserEntity.h
Go to the documentation of this file.
1 
2 // DropSpenser.h
3 
4 // Declares the cDropSpenser class representing a common ancestor to the cDispenserEntity and cDropperEntity
5 // The dropper and dispenser only needs to override the DropSpenseFromSlot() function to provide the specific item behavior
6 
7 
8 
9 
10 
11 #pragma once
12 
13 #include "BlockEntityWithItems.h"
14 
15 
16 
17 
18 
19 class cClientHandle;
20 
21 
22 
23 
24 
25 // tolua_begin
28 {
29  // tolua_end
30 
32 
33  // tolua_begin
34 
35 public:
36 
37  enum
38  {
41  } ;
42 
43  // tolua_end
44 
45  cDropSpenserEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World);
46 
47  // cBlockEntity overrides:
48  virtual void CopyFrom(const cBlockEntity & a_Src) override;
49  virtual void OnRemoveFromWorld() override;
50  virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
51  virtual void SendTo(cClientHandle & a_Client) override;
52  virtual bool UsedBy(cPlayer * a_Player) override;
53 
54  // tolua_begin
55 
57  void AddDropSpenserDir(Vector3i & a_RelCoord, NIBBLETYPE a_Direction);
58 
60  void Activate(void);
61 
62  // tolua_end
63 
64 protected:
65 
67 
69  void DropSpense(cChunk & a_Chunk);
70 
72  virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) = 0;
73 
75  void DropFromSlot(cChunk & a_Chunk, int a_SlotNum);
76 } ; // 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 DropSpenseFromSlot(cChunk &a_Chunk, int a_SlotNum)=0
Override this function to provide the specific behavior for item dropspensing (drop / shoot / pour / ...
virtual bool UsedBy(cPlayer *a_Player) override
Called when a player uses this entity; should open the UI window.
void DropFromSlot(cChunk &a_Chunk, int a_SlotNum)
Helper function, drops one item from the specified slot (like a dropper)
void DropSpense(cChunk &a_Chunk)
Does the actual work on dropspensing an item.
virtual void SendTo(cClientHandle &a_Client) override
Sends the packet defining the block entity to the client specified.
void Activate(void)
Sets the dropspenser to dropspense an item in the next tick.
cDropSpenserEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
bool m_ShouldDropSpense
If true, the dropspenser will dropspense an item in the next tick.
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking.
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
virtual void OnRemoveFromWorld() override
Called when the block entity object is removed from a world.
void AddDropSpenserDir(Vector3i &a_RelCoord, NIBBLETYPE a_Direction)
Modifies the block coords to match the dropspenser direction given (where the dropspensed pickups sho...
Definition: Chunk.h:36
Definition: Player.h:29
Definition: World.h:53