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

#include <BeaconEntity.h>

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

Public Member Functions

char CalculatePyramidLevel (void)
 Calculate the amount of layers the pyramid below the beacon has. More...
 
 cBeaconEntity (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...
 
char GetBeaconLevel (void) const
 Returns the beacon level. More...
 
cEntityEffect::eType GetPrimaryEffect (void) const
 
cEntityEffect::eType GetSecondaryEffect (void) const
 
void GiveEffects (void)
 Give the near-players the effects. More...
 
bool IsActive (void) const
 Is the beacon active? More...
 
bool IsBeaconBlocked (void)
 Is the beacon blocked by non-transparent blocks that are higher than the beacon? 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...
 
void SetBeaconLevel (char a_Level)
 Modify the beacon level. More...
 
bool SetPrimaryEffect (cEntityEffect::eType a_Effect)
 Sets the primary effect. More...
 
bool SetSecondaryEffect (cEntityEffect::eType a_Effect)
 Sets the secondary effect. 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...
 
void UpdateBeacon (void)
 Update the beacon. 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 bool IsMineralBlock (BLOCKTYPE a_BlockType)
 Returns true if the block is a diamond block, a golden block, an iron block or an emerald block. More...
 
static bool IsValidEffect (cEntityEffect::eType a_Effect, char a_BeaconLevel)
 Returns true if the effect can be used. 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...
 

Protected Attributes

char m_BeaconLevel
 
bool m_IsActive
 
cEntityEffect::eType m_PrimaryEffect
 
cEntityEffect::eType m_SecondaryEffect
 
- 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

- 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)
 

Detailed Description

Definition at line 19 of file BeaconEntity.h.

Member Typedef Documentation

◆ Super

Definition at line 24 of file BeaconEntity.h.

Constructor & Destructor Documentation

◆ cBeaconEntity()

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

Definition at line 15 of file BeaconEntity.cpp.

Member Function Documentation

◆ CalculatePyramidLevel()

char cBeaconEntity::CalculatePyramidLevel ( void  )

Calculate the amount of layers the pyramid below the beacon has.

Definition at line 33 of file BeaconEntity.cpp.

◆ CopyFrom()

void cBeaconEntity::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 259 of file BeaconEntity.cpp.

◆ GetBeaconLevel()

char cBeaconEntity::GetBeaconLevel ( void  ) const
inline

Returns the beacon level.

(0 - 4)

Definition at line 46 of file BeaconEntity.h.

◆ GetPrimaryEffect()

cEntityEffect::eType cBeaconEntity::GetPrimaryEffect ( void  ) const
inline

Definition at line 48 of file BeaconEntity.h.

◆ GetSecondaryEffect()

cEntityEffect::eType cBeaconEntity::GetSecondaryEffect ( void  ) const
inline

Definition at line 49 of file BeaconEntity.h.

◆ GiveEffects()

void cBeaconEntity::GiveEffects ( void  )

Give the near-players the effects.

Definition at line 221 of file BeaconEntity.cpp.

◆ IsActive()

bool cBeaconEntity::IsActive ( void  ) const
inline

Is the beacon active?

Definition at line 43 of file BeaconEntity.h.

◆ IsBeaconBlocked()

bool cBeaconEntity::IsBeaconBlocked ( void  )

Is the beacon blocked by non-transparent blocks that are higher than the beacon?

Definition at line 140 of file BeaconEntity.cpp.

◆ IsMineralBlock()

bool cBeaconEntity::IsMineralBlock ( BLOCKTYPE  a_BlockType)
static

Returns true if the block is a diamond block, a golden block, an iron block or an emerald block.

Definition at line 157 of file BeaconEntity.cpp.

◆ IsValidEffect()

bool cBeaconEntity::IsValidEffect ( cEntityEffect::eType  a_Effect,
char  a_BeaconLevel 
)
static

Returns true if the effect can be used.

Definition at line 72 of file BeaconEntity.cpp.

◆ OnRemoveFromWorld()

void cBeaconEntity::OnRemoveFromWorld ( )
overridevirtual

Called when the block entity object is removed from a world.

This occurs when the chunk it resides in is unloaded, or when the associated block is destroyed. If it is the latter, Destroy() is guaranteed to be called first.

Reimplemented from cBlockEntity.

Definition at line 274 of file BeaconEntity.cpp.

◆ SendTo()

void cBeaconEntity::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 288 of file BeaconEntity.cpp.

◆ SetBeaconLevel()

void cBeaconEntity::SetBeaconLevel ( char  a_Level)
inline

Modify the beacon level.

(It is needed to load the beacon corectly)

Definition at line 38 of file BeaconEntity.h.

◆ SetPrimaryEffect()

bool cBeaconEntity::SetPrimaryEffect ( cEntityEffect::eType  a_Effect)

Sets the primary effect.

Returns false when the effect is invalid.

Definition at line 96 of file BeaconEntity.cpp.

◆ SetSecondaryEffect()

bool cBeaconEntity::SetSecondaryEffect ( cEntityEffect::eType  a_Effect)

Sets the secondary effect.

Returns false when the effect is invalid.

Definition at line 118 of file BeaconEntity.cpp.

◆ Tick()

bool cBeaconEntity::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 297 of file BeaconEntity.cpp.

◆ UpdateBeacon()

void cBeaconEntity::UpdateBeacon ( void  )

Update the beacon.

Definition at line 176 of file BeaconEntity.cpp.

◆ UsedBy()

bool cBeaconEntity::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 314 of file BeaconEntity.cpp.

Member Data Documentation

◆ m_BeaconLevel

char cBeaconEntity::m_BeaconLevel
protected

Definition at line 80 of file BeaconEntity.h.

◆ m_IsActive

bool cBeaconEntity::m_IsActive
protected

Definition at line 79 of file BeaconEntity.h.

◆ m_PrimaryEffect

cEntityEffect::eType cBeaconEntity::m_PrimaryEffect
protected

Definition at line 82 of file BeaconEntity.h.

◆ m_SecondaryEffect

cEntityEffect::eType cBeaconEntity::m_SecondaryEffect
protected

Definition at line 82 of file BeaconEntity.h.


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