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

#include <DropSpenserEntity.h>

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

Public Types

enum  { ContentsHeight = 3, ContentsWidth = 3 }
 

Public Member Functions

void Activate (void)
 Sets the dropspenser to dropspense an item in the next tick. More...
 
void AddDropSpenserDir (Vector3i &a_RelCoord, NIBBLETYPE a_Direction)
 Modifies the block coords to match the dropspenser direction given (where the dropspensed pickups should materialize) More...
 
 cDropSpenserEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 
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...
 
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...
 
virtual ~cDropSpenserEntity () override
 
- 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 void Destroy (void) override
 
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
cBlockEntityClone (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...
 
BLOCKTYPE GetBlockType () const
 
int GetChunkX () const
 
int GetChunkZ () const
 
virtual const char * GetClass () const
 Returns the name of the topmost class (the most descendant). More...
 
virtual const char * GetParentClass () const
 Returns the name of the parent class, or empty string if no parent class. More...
 
Vector3i GetPos () const
 
int GetPosX () const
 
int GetPosY () const
 
int GetPosZ () const
 
Vector3i GetRelPos () const
 
int GetRelX () const
 
int GetRelZ () const
 
cWorldGetWorld () const
 
virtual bool IsA (const char *a_ClassName) const
 Returns true if the object is the specified class, or its descendant. More...
 
void SetPos (Vector3i a_NewPos)
 Updates the internally stored position. More...
 
void SetWorld (cWorld *a_World)
 
virtual ~cBlockEntity ()
 
- 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

void DropFromSlot (cChunk &a_Chunk, int a_SlotNum)
 Helper function, drops one item from the specified slot (like a dropper) More...
 
void DropSpense (cChunk &a_Chunk)
 Does the actual work on dropspensing an item. More...
 
virtual void DropSpenseFromSlot (cChunk &a_Chunk, int a_SlotNum)=0
 Override this function to provide the specific behavior for item dropspensing (drop / shoot / pour / ...) 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

bool m_ShouldDropSpense
 If true, the dropspenser will dropspense an item in the next tick. More...
 
- 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
 

Additional Inherited Members

- Static Public Member Functions inherited from cBlockEntity
static cBlockEntityCreateByBlockType (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 const char * GetClassStatic ()
 
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 26 of file DropSpenserEntity.h.

Member Typedef Documentation

Definition at line 31 of file DropSpenserEntity.h.

Member Enumeration Documentation

anonymous enum
Enumerator
ContentsHeight 
ContentsWidth 

Definition at line 37 of file DropSpenserEntity.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file DropSpenserEntity.cpp.

cDropSpenserEntity::~cDropSpenserEntity ( )
overridevirtual

Definition at line 28 of file DropSpenserEntity.cpp.

Member Function Documentation

void cDropSpenserEntity::Activate ( void  )

Sets the dropspenser to dropspense an item in the next tick.

Definition at line 107 of file DropSpenserEntity.cpp.

void cDropSpenserEntity::AddDropSpenserDir ( Vector3i a_RelCoord,
NIBBLETYPE  a_Direction 
)

Modifies the block coords to match the dropspenser direction given (where the dropspensed pickups should materialize)

Definition at line 42 of file DropSpenserEntity.cpp.

void cDropSpenserEntity::CopyFrom ( const cBlockEntity a_Src)
overridevirtual

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 116 of file DropSpenserEntity.cpp.

void cDropSpenserEntity::DropFromSlot ( cChunk a_Chunk,
int  a_SlotNum 
)
protected

Helper function, drops one item from the specified slot (like a dropper)

Definition at line 178 of file DropSpenserEntity.cpp.

void cDropSpenserEntity::DropSpense ( cChunk a_Chunk)
protected

Does the actual work on dropspensing an item.

Chooses the slot, calls DropSpenseFromSlot() and handles smoke / sound effects

Definition at line 61 of file DropSpenserEntity.cpp.

virtual void cDropSpenserEntity::DropSpenseFromSlot ( cChunk a_Chunk,
int  a_SlotNum 
)
protectedpure virtual

Override this function to provide the specific behavior for item dropspensing (drop / shoot / pour / ...)

Implemented in cDispenserEntity, and cDropperEntity.

void cDropSpenserEntity::SendTo ( cClientHandle a_Client)
overridevirtual

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 145 of file DropSpenserEntity.cpp.

bool cDropSpenserEntity::Tick ( std::chrono::milliseconds  a_Dt,
cChunk a_Chunk 
)
overridevirtual

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 128 of file DropSpenserEntity.cpp.

bool cDropSpenserEntity::UsedBy ( cPlayer a_Player)
overridevirtual

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 155 of file DropSpenserEntity.cpp.

Member Data Documentation

bool cDropSpenserEntity::m_ShouldDropSpense
protected

If true, the dropspenser will dropspense an item in the next tick.

Definition at line 67 of file DropSpenserEntity.h.


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