Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Attributes | List of all members
cHopperEntity Class Reference

#include <HopperEntity.h>

Inheritance diagram for cHopperEntity:
Inheritance graph
[legend]
Collaboration diagram for cHopperEntity:
Collaboration graph
[legend]

Public Types

enum  { ContentsHeight = 1 , ContentsWidth = 5 }
 

Public Member Functions

 cHopperEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 Constructor used for normal operation. More...
 
std::pair< bool, Vector3iGetOutputBlockPos (NIBBLETYPE a_BlockMeta)
 Returns the block coords of the block receiving the output items, based on the meta Returns <false, undefined> if unattached. More...
 
void SetLocked (bool a_Value)
 
- Public Member Functions inherited from cBlockEntityWithItems
 cBlockEntityWithItems (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, int a_ItemGridWidth, int a_ItemGridHeight, cWorld *a_World)
 
virtual cItems ConvertToPickups () const override
 Returns the contents of this block entity that it would drop if broken. More...
 
cItemGridGetContents (void)
 Returns the ItemGrid used for storing the contents. More...
 
const cItemGridGetContents (void) const
 Const version of the GetContents() function for C++ type-safety. More...
 
const cItemGetSlot (int a_SlotNum) const
 
const cItemGetSlot (int a_X, int a_Y) const
 
void SetSlot (int a_SlotNum, const cItem &a_Item)
 
void SetSlot (int a_X, int a_Y, const cItem &a_Item)
 
- Public Member Functions inherited from cBlockEntity
OwnedBlockEntity Clone (Vector3i a_Pos)
 Makes an exact copy of this block entity, except for its m_World (set to nullptr), and at a new position. More...
 
virtual void Destroy ()
 Called when this block entity's associated block is destroyed. More...
 
BLOCKTYPE GetBlockType () const
 
int GetChunkX () const
 
int GetChunkZ () const
 
Vector3i GetPos () const
 
int GetPosX () const
 
int GetPosY () const
 
int GetPosZ () const
 
Vector3i GetRelPos () const
 
int GetRelX () const
 
int GetRelZ () const
 
cWorldGetWorld () const
 
virtual void OnAddToWorld (cWorld &a_World, cChunk &a_Chunk)
 Called when the block entity object is added to a world. More...
 
virtual void OnRemoveFromWorld ()
 Called when the block entity object is removed from a world. More...
 
void SetPos (Vector3i a_NewPos)
 Updates the internally stored position. More...
 
void SetWorld (cWorld *a_World)
 
virtual ~cBlockEntity ()=default
 
- Public Member Functions inherited from cItemGrid::cListener
virtual ~cListener ()
 
- Public Member Functions inherited from cBlockEntityWindowOwner
 cBlockEntityWindowOwner (cBlockEntity *a_BlockEntity)
 
virtual Vector3i GetBlockPos (void) override
 Returns the block position at which the element owning the window is. More...
 
- Public Member Functions inherited from cWindowOwner
void CloseWindow (void)
 
 cWindowOwner ()
 
cWindowGetWindow (void) const
 
void OpenWindow (cWindow *a_Window)
 
virtual ~cWindowOwner ()
 

Protected Member Functions

virtual void CopyFrom (const cBlockEntity &a_Src) override
 Copies all properties of a_Src into this entity, except for its m_World and location. More...
 
bool MoveItemsFromChest (cChunk &a_Chunk)
 Moves items from a chest (dblchest) above the hopper into this hopper. More...
 
bool MoveItemsFromFurnace (cChunk &a_Chunk)
 Moves items from a furnace above the hopper into this hopper. More...
 
bool MoveItemsFromGrid (cBlockEntityWithItems &a_Entity)
 Moves items from the specified a_Entity's Contents into this hopper. More...
 
bool MoveItemsFromSlot (cBlockEntityWithItems &a_Entity, int a_SrcSlotNum)
 Moves one piece from the specified itemstack into this hopper. More...
 
bool MoveItemsIn (cChunk &a_Chunk, cTickTimeLong a_CurrentTick)
 Moves items from the container above it into this hopper. More...
 
bool MoveItemsOut (cChunk &a_Chunk, cTickTimeLong a_CurrentTick)
 Moves items out from this hopper into the destination. More...
 
bool MoveItemsToChest (cChunk &a_Chunk, Vector3i a_Coords)
 Moves items to the chest at the specified absolute coords. More...
 
bool MoveItemsToFurnace (cChunk &a_Chunk, Vector3i a_Coords, NIBBLETYPE a_HopperMeta)
 Moves items to the furnace at the specified absolute coords. More...
 
bool MoveItemsToGrid (cBlockEntityWithItems &a_Entity)
 Moves items to the specified ItemGrid. More...
 
bool MoveItemsToSlot (cBlockEntityWithItems &a_Entity, int a_DstSlotNum)
 Moves one piece to the specified entity's contents' slot. More...
 
bool MovePickupsIn (cChunk &a_Chunk)
 Moves pickups from above this hopper into it. More...
 
void OpenNewWindow (void)
 Opens a new chest window for this chest. More...
 
virtual void SendTo (cClientHandle &a_Client) override
 Sends the packet defining the block entity to the client specified. More...
 
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. More...
 
virtual bool UsedBy (cPlayer *a_Player) override
 Called when a player uses this entity; should open the UI window. More...
 
- Protected Member Functions inherited from cBlockEntityWithItems
virtual void OnSlotChanged (cItemGrid *a_Grid, int a_SlotNum) override
 Called whenever a slot changes. More...
 
- Protected Member Functions inherited from cBlockEntity
 cBlockEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 

Protected Attributes

cTickTimeLong m_LastMoveItemsInTick
 
cTickTimeLong m_LastMoveItemsOutTick
 
- Protected Attributes inherited from cBlockEntityWithItems
cItemGrid m_Contents
 
- Protected Attributes inherited from cBlockEntity
NIBBLETYPE m_BlockMeta
 The block meta representing this particular instance in the world Mainly used for directional entities, such as dispensers. More...
 
BLOCKTYPE m_BlockType
 The blocktype representing this particular instance in the world. More...
 
Vector3i m_Pos
 Position in absolute block coordinates. More...
 
int m_RelX
 Position relative to the chunk, used to speed up ticking. More...
 
int m_RelZ
 
cWorldm_World
 

Private Types

using Super = cBlockEntityWithItems
 

Private Attributes

bool m_Locked
 

Additional Inherited Members

- Static Public Member Functions inherited from cBlockEntity
static OwnedBlockEntity CreateByBlockType (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World=nullptr)
 Creates a new block entity for the specified block type at the specified absolute pos. More...
 
static bool IsBlockEntityBlockType (BLOCKTYPE a_BlockType)
 Returns true if the specified blocktype is supposed to have an associated block entity. More...
 

Detailed Description

Definition at line 19 of file HopperEntity.h.

Member Typedef Documentation

◆ Super

Definition at line 24 of file HopperEntity.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
ContentsHeight 
ContentsWidth 

Definition at line 30 of file HopperEntity.h.

Constructor & Destructor Documentation

◆ cHopperEntity()

cHopperEntity::cHopperEntity ( BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta,
Vector3i  a_Pos,
cWorld a_World 
)

Constructor used for normal operation.

Definition at line 27 of file HopperEntity.cpp.

Member Function Documentation

◆ CopyFrom()

void cHopperEntity::CopyFrom ( const cBlockEntity a_Src)
overrideprotectedvirtual

Copies all properties of a_Src into this entity, except for its m_World and location.

Each non-abstract descendant should override to copy its specific properties, and call Super::CopyFrom(a_Src) to copy the common ones.

Reimplemented from cBlockEntityWithItems.

Definition at line 71 of file HopperEntity.cpp.

◆ GetOutputBlockPos()

std::pair< bool, Vector3i > cHopperEntity::GetOutputBlockPos ( NIBBLETYPE  a_BlockMeta)

Returns the block coords of the block receiving the output items, based on the meta Returns <false, undefined> if unattached.

Exported in ManualBindings.cpp.

Definition at line 49 of file HopperEntity.cpp.

◆ MoveItemsFromChest()

bool cHopperEntity::MoveItemsFromChest ( cChunk a_Chunk)
protected

Moves items from a chest (dblchest) above the hopper into this hopper.

Returns true if contents have changed.

Definition at line 370 of file HopperEntity.cpp.

◆ MoveItemsFromFurnace()

bool cHopperEntity::MoveItemsFromFurnace ( cChunk a_Chunk)
protected

Moves items from a furnace above the hopper into this hopper.

Returns true if contents have changed.

Definition at line 394 of file HopperEntity.cpp.

◆ MoveItemsFromGrid()

bool cHopperEntity::MoveItemsFromGrid ( cBlockEntityWithItems a_Entity)
protected

Moves items from the specified a_Entity's Contents into this hopper.

Returns true if contents have changed.

Definition at line 429 of file HopperEntity.cpp.

◆ MoveItemsFromSlot()

bool cHopperEntity::MoveItemsFromSlot ( cBlockEntityWithItems a_Entity,
int  a_SrcSlotNum 
)
protected

Moves one piece from the specified itemstack into this hopper.

Returns true if contents have changed. Doesn't change the itemstack.

Definition at line 453 of file HopperEntity.cpp.

◆ MoveItemsIn()

bool cHopperEntity::MoveItemsIn ( cChunk a_Chunk,
cTickTimeLong  a_CurrentTick 
)
protected

Moves items from the container above it into this hopper.

Returns true if the contents have changed.

Definition at line 151 of file HopperEntity.cpp.

◆ MoveItemsOut()

bool cHopperEntity::MoveItemsOut ( cChunk a_Chunk,
cTickTimeLong  a_CurrentTick 
)
protected

Moves items out from this hopper into the destination.

Returns true if the contents have changed.

Definition at line 292 of file HopperEntity.cpp.

◆ MoveItemsToChest()

bool cHopperEntity::MoveItemsToChest ( cChunk a_Chunk,
Vector3i  a_Coords 
)
protected

Moves items to the chest at the specified absolute coords.

Returns true if contents have changed

Definition at line 494 of file HopperEntity.cpp.

◆ MoveItemsToFurnace()

bool cHopperEntity::MoveItemsToFurnace ( cChunk a_Chunk,
Vector3i  a_Coords,
NIBBLETYPE  a_HopperMeta 
)
protected

Moves items to the furnace at the specified absolute coords.

Returns true if contents have changed

Definition at line 518 of file HopperEntity.cpp.

◆ MoveItemsToGrid()

bool cHopperEntity::MoveItemsToGrid ( cBlockEntityWithItems a_Entity)
protected

Moves items to the specified ItemGrid.

Returns true if contents have changed

Definition at line 537 of file HopperEntity.cpp.

◆ MoveItemsToSlot()

bool cHopperEntity::MoveItemsToSlot ( cBlockEntityWithItems a_Entity,
int  a_DstSlotNum 
)
protected

Moves one piece to the specified entity's contents' slot.

Returns true if contents have changed.

Definition at line 555 of file HopperEntity.cpp.

◆ MovePickupsIn()

bool cHopperEntity::MovePickupsIn ( cChunk a_Chunk)
protected

Moves pickups from above this hopper into it.

Returns true if the contents have changed.

Definition at line 205 of file HopperEntity.cpp.

◆ OpenNewWindow()

void cHopperEntity::OpenNewWindow ( void  )
protected

Opens a new chest window for this chest.

Scans for neighbors to open a double chest window, if appropriate.

Definition at line 142 of file HopperEntity.cpp.

◆ SendTo()

void cHopperEntity::SendTo ( cClientHandle a_Client)
overrideprotectedvirtual

Sends the packet defining the block entity to the client specified.

To send to all eligible clients, use cWorld::BroadcastBlockEntity()

Implements cBlockEntity.

Definition at line 102 of file HopperEntity.cpp.

◆ SetLocked()

void cHopperEntity::SetLocked ( bool  a_Value)

Definition at line 40 of file HopperEntity.cpp.

◆ Tick()

bool cHopperEntity::Tick ( std::chrono::milliseconds  a_Dt,
cChunk a_Chunk 
)
overrideprotectedvirtual

Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking.

By default does nothing.

Reimplemented from cBlockEntity.

Definition at line 83 of file HopperEntity.cpp.

◆ UsedBy()

bool cHopperEntity::UsedBy ( cPlayer a_Player)
overrideprotectedvirtual

Called when a player uses this entity; should open the UI window.

returns true if the use was successful, return false to use the block as a "normal" block

Implements cBlockEntity.

Definition at line 114 of file HopperEntity.cpp.

Member Data Documentation

◆ m_LastMoveItemsInTick

cTickTimeLong cHopperEntity::m_LastMoveItemsInTick
protected

Definition at line 50 of file HopperEntity.h.

◆ m_LastMoveItemsOutTick

cTickTimeLong cHopperEntity::m_LastMoveItemsOutTick
protected

Definition at line 51 of file HopperEntity.h.

◆ m_Locked

bool cHopperEntity::m_Locked
private

Definition at line 97 of file HopperEntity.h.


The documentation for this class was generated from the following files: