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

#include <JukeboxEntity.h>

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

Public Member Functions

 cJukeboxEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 
virtual cItems ConvertToPickups () const override
 Returns the contents of this block entity that it would drop if broken. More...
 
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 Destroy (void) override
 Called when this block entity's associated block is destroyed. More...
 
bool EjectRecord (void)
 Ejects the currently held record as a pickup. More...
 
int GetRecord (void)
 
bool IsPlayingRecord (void) const
 Is in the Jukebox a Record? More...
 
bool PlayRecord (int a_Record)
 Plays the specified Record. More...
 
virtual void SendTo (cClientHandle &) override
 Sends the packet defining the block entity to the client specified. More...
 
void SetRecord (int a_Record)
 
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 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...
 
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 bool Tick (std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
 Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking. More...
 
virtual ~cBlockEntity ()=default
 

Static Public Member Functions

static bool IsRecordItem (int a_Item)
 
- 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 = cBlockEntity
 

Private Attributes

int m_Record
 

Additional Inherited Members

- Protected Member Functions inherited from cBlockEntity
 cBlockEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 
- 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 13 of file JukeboxEntity.h.

Member Typedef Documentation

◆ Super

Definition at line 18 of file JukeboxEntity.h.

Constructor & Destructor Documentation

◆ cJukeboxEntity()

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

Definition at line 16 of file JukeboxEntity.cpp.

Member Function Documentation

◆ ConvertToPickups()

cItems cJukeboxEntity::ConvertToPickups ( ) const
overridevirtual

Returns the contents of this block entity that it would drop if broken.

Note that the block handler will usually handle pickups for the block itself, in addition to any items returned here.

Reimplemented from cBlockEntity.

Definition at line 37 of file JukeboxEntity.cpp.

◆ CopyFrom()

void cJukeboxEntity::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 cBlockEntity.

Definition at line 46 of file JukeboxEntity.cpp.

◆ Destroy()

void cJukeboxEntity::Destroy ( void  )
overridevirtual

Called when this block entity's associated block is destroyed.

It is guaranteed that this function is called before OnRemoveFromWorld.

Reimplemented from cBlockEntity.

Definition at line 27 of file JukeboxEntity.cpp.

◆ EjectRecord()

bool cJukeboxEntity::EjectRecord ( void  )

Ejects the currently held record as a pickup.

Return false when no record had been inserted.

Definition at line 110 of file JukeboxEntity.cpp.

◆ GetRecord()

int cJukeboxEntity::GetRecord ( void  )

Definition at line 139 of file JukeboxEntity.cpp.

◆ IsPlayingRecord()

bool cJukeboxEntity::IsPlayingRecord ( void  ) const

Is in the Jukebox a Record?

Definition at line 130 of file JukeboxEntity.cpp.

◆ IsRecordItem()

static bool cJukeboxEntity::IsRecordItem ( int  a_Item)
inlinestatic

Definition at line 39 of file JukeboxEntity.h.

◆ PlayRecord()

bool cJukeboxEntity::PlayRecord ( int  a_Record)

Plays the specified Record.

Return false if a_Record isn't a playable Record (E_ITEM_XXX_DISC). If there is a record already playing, ejects it first.

Definition at line 86 of file JukeboxEntity.cpp.

◆ SendTo()

virtual void cJukeboxEntity::SendTo ( cClientHandle a_Client)
inlineoverridevirtual

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 51 of file JukeboxEntity.h.

◆ SetRecord()

void cJukeboxEntity::SetRecord ( int  a_Record)

Definition at line 148 of file JukeboxEntity.cpp.

◆ UsedBy()

bool cJukeboxEntity::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 57 of file JukeboxEntity.cpp.

Member Data Documentation

◆ m_Record

int cJukeboxEntity::m_Record
private

Definition at line 54 of file JukeboxEntity.h.


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