Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <HopperEntity.h>
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, Vector3i > | GetOutputBlockPos (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... | |
cItemGrid & | GetContents (void) |
Returns the ItemGrid used for storing the contents. More... | |
const cItemGrid & | GetContents (void) const |
Const version of the GetContents() function for C++ type-safety. More... | |
const cItem & | GetSlot (int a_SlotNum) const |
const cItem & | GetSlot (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 |
cWorld * | GetWorld () 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 () | |
cWindow * | GetWindow (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 |
cWorld * | m_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... | |
Definition at line 19 of file HopperEntity.h.
|
private |
Definition at line 24 of file HopperEntity.h.
anonymous enum |
Enumerator | |
---|---|
ContentsHeight | |
ContentsWidth |
Definition at line 30 of file HopperEntity.h.
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.
|
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.
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
Moves items to the chest at the specified absolute coords.
Returns true if contents have changed
Definition at line 494 of file HopperEntity.cpp.
|
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.
|
protected |
Moves items to the specified ItemGrid.
Returns true if contents have changed
Definition at line 537 of file HopperEntity.cpp.
|
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.
|
protected |
Moves pickups from above this hopper into it.
Returns true if the contents have changed.
Definition at line 205 of file HopperEntity.cpp.
|
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.
|
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.
void cHopperEntity::SetLocked | ( | bool | a_Value | ) |
Definition at line 40 of file HopperEntity.cpp.
|
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.
|
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.
|
protected |
Definition at line 50 of file HopperEntity.h.
|
protected |
Definition at line 51 of file HopperEntity.h.
|
private |
Definition at line 97 of file HopperEntity.h.