Cuberite
A lightweight, fast and extensible game server for Minecraft
HopperEntity.h
Go to the documentation of this file.
1 
2 // HopperEntity.h
3 
4 // Declares the cHopperEntity representing a hopper block entity
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "BlockEntityWithItems.h"
13 
14 
15 
16 
17 
18 // tolua_begin
21 {
22  // tolua_end
23 
25 
26  // tolua_begin
27 
28 public:
29 
30  enum
31  {
33  ContentsWidth = 5
34  } ;
35 
36  // tolua_end
37 
39  cHopperEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World);
40 
44  std::pair<bool, Vector3i> GetOutputBlockPos(NIBBLETYPE a_BlockMeta);
45 
46  void SetLocked(bool a_Value);
47 
48 protected:
49 
52 
53  // cBlockEntity overrides:
54  virtual void CopyFrom(const cBlockEntity & a_Src) override;
55  virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
56  virtual void SendTo(cClientHandle & a_Client) override;
57  virtual bool UsedBy(cPlayer * a_Player) override;
58 
60  void OpenNewWindow(void);
61 
63  bool MoveItemsIn(cChunk & a_Chunk, cTickTimeLong a_CurrentTick);
64 
66  bool MovePickupsIn(cChunk & a_Chunk);
67 
69  bool MoveItemsOut(cChunk & a_Chunk, cTickTimeLong a_CurrentTick);
70 
72  bool MoveItemsFromChest(cChunk & a_Chunk);
73 
75  bool MoveItemsFromFurnace(cChunk & a_Chunk);
76 
79 
81  bool MoveItemsFromSlot(cBlockEntityWithItems & a_Entity, int a_SrcSlotNum);
82 
84  bool MoveItemsToChest(cChunk & a_Chunk, Vector3i a_Coords);
85 
87  bool MoveItemsToFurnace(cChunk & a_Chunk, Vector3i a_Coords, NIBBLETYPE a_HopperMeta);
88 
90  bool MoveItemsToGrid(cBlockEntityWithItems & a_Entity);
91 
93  bool MoveItemsToSlot(cBlockEntityWithItems & a_Entity, int a_DstSlotNum);
94 
95 private:
96 
97  bool m_Locked;
98 } ; // 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
std::chrono::duration< signed long long int, cTickTime::period > cTickTimeLong
Definition: Globals.h:367
cBlockEntityWithItems(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, int a_ItemGridWidth, int a_ItemGridHeight, cWorld *a_World)
bool MoveItemsIn(cChunk &a_Chunk, cTickTimeLong a_CurrentTick)
Moves items from the container above it into this hopper.
virtual void SendTo(cClientHandle &a_Client) override
Sends the packet defining the block entity to the client specified.
bool MoveItemsToGrid(cBlockEntityWithItems &a_Entity)
Moves items to the specified ItemGrid.
cHopperEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
Constructor used for normal operation.
void SetLocked(bool a_Value)
bool MoveItemsToSlot(cBlockEntityWithItems &a_Entity, int a_DstSlotNum)
Moves one piece to the specified entity's contents' slot.
bool MoveItemsToChest(cChunk &a_Chunk, Vector3i a_Coords)
Moves items to the chest at the specified absolute coords.
bool MoveItemsToFurnace(cChunk &a_Chunk, Vector3i a_Coords, NIBBLETYPE a_HopperMeta)
Moves items to the furnace at the specified absolute coords.
bool MoveItemsOut(cChunk &a_Chunk, cTickTimeLong a_CurrentTick)
Moves items out from this hopper into the destination.
void OpenNewWindow(void)
Opens a new chest window for this chest.
bool MoveItemsFromFurnace(cChunk &a_Chunk)
Moves items from a furnace above the hopper into this hopper.
cTickTimeLong m_LastMoveItemsInTick
Definition: HopperEntity.h:50
virtual bool UsedBy(cPlayer *a_Player) override
Called when a player uses this entity; should open the UI window.
bool MovePickupsIn(cChunk &a_Chunk)
Moves pickups from above this hopper into it.
bool MoveItemsFromChest(cChunk &a_Chunk)
Moves items from a chest (dblchest) above the hopper into this hopper.
std::pair< bool, Vector3i > GetOutputBlockPos(NIBBLETYPE a_BlockMeta)
Returns the block coords of the block receiving the output items, based on the meta Returns <false,...
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
cTickTimeLong m_LastMoveItemsOutTick
Definition: HopperEntity.h:51
bool MoveItemsFromSlot(cBlockEntityWithItems &a_Entity, int a_SrcSlotNum)
Moves one piece from the specified itemstack into this hopper.
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.
bool MoveItemsFromGrid(cBlockEntityWithItems &a_Entity)
Moves items from the specified a_Entity's Contents into this hopper.
Definition: Chunk.h:36
Definition: Player.h:29
Definition: World.h:53