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
cNoteEntity Class Reference

#include <NoteEntity.h>

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

Public Member Functions

 cNoteEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 Creates a new note entity. 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...
 
unsigned char GetNote (void)
 
void IncrementNote (void)
 
void MakeSound (void)
 
virtual void SendTo (cClientHandle &) override
 Sends the packet defining the block entity to the client specified. More...
 
void SetNote (unsigned char a_Note)
 
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...
 
virtual cItems ConvertToPickups () const
 Returns the contents of this block entity that it would drop if broken. 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 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 float PitchFromNote (unsigned char a_Note)
 Returns the relative pitch (used in the protocol) from a note value between 0 and 24 (used in m_Note). 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 = cBlockEntity
 

Private Attributes

unsigned char m_Note
 

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 30 of file NoteEntity.h.

Member Typedef Documentation

◆ Super

Definition at line 35 of file NoteEntity.h.

Constructor & Destructor Documentation

◆ cNoteEntity()

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

Creates a new note entity.

a_World may be nullptr

Definition at line 13 of file NoteEntity.cpp.

Member Function Documentation

◆ CopyFrom()

void cNoteEntity::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 24 of file NoteEntity.cpp.

◆ GetNote()

unsigned char cNoteEntity::GetNote ( void  )

Definition at line 261 of file NoteEntity.cpp.

◆ IncrementNote()

void cNoteEntity::IncrementNote ( void  )

Definition at line 279 of file NoteEntity.cpp.

◆ MakeSound()

void cNoteEntity::MakeSound ( void  )

Definition at line 47 of file NoteEntity.cpp.

◆ PitchFromNote()

float cNoteEntity::PitchFromNote ( unsigned char  a_Note)
static

Returns the relative pitch (used in the protocol) from a note value between 0 and 24 (used in m_Note).

Definition at line 288 of file NoteEntity.cpp.

◆ SendTo()

virtual void cNoteEntity::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 54 of file NoteEntity.h.

◆ SetNote()

void cNoteEntity::SetNote ( unsigned char  a_Note)

Definition at line 270 of file NoteEntity.cpp.

◆ UsedBy()

bool cNoteEntity::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 35 of file NoteEntity.cpp.

Member Data Documentation

◆ m_Note

unsigned char cNoteEntity::m_Note
private

Definition at line 62 of file NoteEntity.h.


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