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

#include <DispenserEntity.h>

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

Public Member Functions

 cDispenserEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 Constructor used for normal operation. More...
 
UInt32 SpawnProjectileFromDispenser (int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d &a_Speed, const cItem *a_Item=nullptr)
 OBSOLETE, use the Vector3i-based overload instead. More...
 
UInt32 SpawnProjectileFromDispenser (Vector3i a_BlockPos, cProjectileEntity::eKind a_Kind, const Vector3d &a_Speed, const cItem *a_Item=nullptr)
 Spawns a projectile of the given kind in front of the dispenser with the specified speed. More...
 
- Public Member Functions inherited from cDropSpenserEntity
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 OnRemoveFromWorld () override
 Called when the block entity object is removed from a world. 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...
 
- 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...
 
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 ()
 

Static Public Member Functions

static Vector3d GetShootVector (NIBBLETYPE a_BlockMeta)
 Returns a unit vector in the cardinal direction of where the dispenser with the specified meta would be facing. More...
 
- 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...
 

Private Types

using Super = cDropSpenserEntity
 

Private Member Functions

virtual void DropSpenseFromSlot (cChunk &a_Chunk, int a_SlotNum) override
 Override this function to provide the specific behavior for item dropspensing (drop / shoot / pour / ...) More...
 
bool EmptyLiquidBucket (BLOCKTYPE a_BlockInFront, int a_SlotNum)
 If the a_BlockInFront can be washed away by liquid and the empty bucket can fit, does the m_Contents processing and returns true. More...
 
bool ScoopUpLiquid (int a_SlotNum, short a_ResultingBucketItemType)
 If such a bucket can fit, adds it to m_Contents and returns true. More...
 

Additional Inherited Members

- Public Types inherited from cDropSpenserEntity
enum  { ContentsHeight = 3 , ContentsWidth = 3 }
 
- Protected Member Functions inherited from cDropSpenserEntity
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...
 
- 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 inherited from cDropSpenserEntity
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
 

Detailed Description

Definition at line 11 of file DispenserEntity.h.

Member Typedef Documentation

◆ Super

Definition at line 16 of file DispenserEntity.h.

Constructor & Destructor Documentation

◆ cDispenserEntity()

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

Constructor used for normal operation.

Definition at line 17 of file DispenserEntity.cpp.

Member Function Documentation

◆ DropSpenseFromSlot()

void cDispenserEntity::DropSpenseFromSlot ( cChunk a_Chunk,
int  a_SlotNum 
)
overrideprivatevirtual

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

Implements cDropSpenserEntity.

Definition at line 27 of file DispenserEntity.cpp.

◆ EmptyLiquidBucket()

bool cDispenserEntity::EmptyLiquidBucket ( BLOCKTYPE  a_BlockInFront,
int  a_SlotNum 
)
private

If the a_BlockInFront can be washed away by liquid and the empty bucket can fit, does the m_Contents processing and returns true.

Returns false otherwise.

Definition at line 337 of file DispenserEntity.cpp.

◆ GetShootVector()

Vector3d cDispenserEntity::GetShootVector ( NIBBLETYPE  a_BlockMeta)
static

Returns a unit vector in the cardinal direction of where the dispenser with the specified meta would be facing.

Definition at line 291 of file DispenserEntity.cpp.

◆ ScoopUpLiquid()

bool cDispenserEntity::ScoopUpLiquid ( int  a_SlotNum,
short  a_ResultingBucketItemType 
)
private

If such a bucket can fit, adds it to m_Contents and returns true.

Definition at line 311 of file DispenserEntity.cpp.

◆ SpawnProjectileFromDispenser() [1/2]

UInt32 cDispenserEntity::SpawnProjectileFromDispenser ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ,
cProjectileEntity::eKind  a_Kind,
const Vector3d a_Speed,
const cItem a_Item = nullptr 
)
inline

OBSOLETE, use the Vector3i-based overload instead.

Spawns a projectile of the given kind in front of the dispenser with the specified speed. a_Item is the item from the internal storage from which the projectile originated. Returns the UniqueID of the spawned projectile, or cEntity::INVALID_ID on failure.

Definition at line 39 of file DispenserEntity.h.

◆ SpawnProjectileFromDispenser() [2/2]

UInt32 cDispenserEntity::SpawnProjectileFromDispenser ( Vector3i  a_BlockPos,
cProjectileEntity::eKind  a_Kind,
const Vector3d a_Speed,
const cItem a_Item = nullptr 
)

Spawns a projectile of the given kind in front of the dispenser with the specified speed.

a_Item is the item from the internal storage from which the projectile originated. Returns the UniqueID of the spawned projectile, or cEntity::INVALID_ID on failure.

Definition at line 280 of file DispenserEntity.cpp.


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