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

#include <FurnaceEntity.h>

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

Public Types

enum  {
  fsInput = 0 , fsFuel = 1 , fsOutput = 2 , ContentsWidth = 3 ,
  ContentsHeight = 1
}
 

Public Member Functions

 cFurnaceEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 Constructor used for normal operation. More...
 
bool ContinueCooking (void)
 Restarts cooking Used after the furnace is loaded from storage to set up the internal variables so that cooking continues, if it was active Returns true if cooking. 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...
 
int GetAndResetReward (void)
 Calculates, resets, and returns the experience reward in this furnace. More...
 
int GetCookTimeLeft (void) const
 Returns the time until the current item finishes cooking, in ticks. More...
 
int GetFuelBurnTimeLeft (void) const
 Returns the time until the current fuel is depleted, in ticks. More...
 
const cItemGetFuelSlot (void) const
 Returns the item in the fuel slot. More...
 
const cItemGetInputSlot (void) const
 Returns the item in the input slot. More...
 
const cItemGetOutputSlot (void) const
 Returns the item in the output slot. More...
 
int GetTimeCooked (void) const
 Returns the time that the current item has been cooking, in ticks. More...
 
bool HasFuelTimeLeft (void) const
 Returns true if there's time left before the current fuel is depleted. 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 SetBurnTimes (int a_FuelBurnTime, int a_TimeBurned)
 
void SetCookTimes (int a_NeedCookTime, int a_TimeCooked)
 
void SetFuelSlot (const cItem &a_Item)
 Sets the item in the fuel slot. More...
 
void SetInputSlot (const cItem &a_Item)
 Sets the item in the input slot. More...
 
void SetLoading (bool a_IsLoading)
 
void SetOutputSlot (const cItem &a_Item)
 Sets the item in the output slot. 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 ()
 

Protected Member Functions

void BroadcastProgress (size_t a_ProgressbarID, short a_Value)
 Sends the specified progressbar value to all clients of the window. More...
 
void BurnNewFuel (void)
 Starts burning a new fuel, if possible. More...
 
bool CanCookInputToOutput (void) const
 Returns true if the input can be cooked into output and the item counts allow for another cooking operation. More...
 
void FinishOne ()
 One item finished cooking. More...
 
virtual void OnSlotChanged (cItemGrid *a_ItemGrid, int a_SlotNum) override
 Called whenever a slot changes. More...
 
void SetIsCooking (bool a_IsCooking)
 Sets the m_IsCooking variable, updates the furnace block type based on the value. More...
 
void UpdateFuel (void)
 Called when the fuel slot changes or when the fuel is spent, burns another piece of fuel if appropriate. More...
 
void UpdateInput (void)
 Updates the recipe, based on the current input. More...
 
void UpdateOutput (void)
 Called when the output slot changes. More...
 
void UpdateProgressBars (bool a_ForceUpdate=false)
 Broadcasts progressbar updates, if needed. More...
 
- Protected Member Functions inherited from cBlockEntity
 cBlockEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 

Protected Attributes

const cFurnaceRecipe::cRecipem_CurrentRecipe
 The recipe for the current input slot. More...
 
int m_FuelBurnTime
 Amount of ticks that the current fuel can burn (in total); zero if no fuel burning. More...
 
bool m_IsCooking
 Set to true if the furnace is cooking an item. More...
 
bool m_IsLoading
 Is the block currently being loaded into the world? More...
 
cItem m_LastInput
 The item that is being smelted. More...
 
int m_NeedCookTime
 Amount of ticks needed to fully cook current item. More...
 
float m_RewardCounter
 Running total of experience that can be picked up. More...
 
int m_TimeBurned
 Amount of ticks that the current fuel has been burning. More...
 
int m_TimeCooked
 Amount of ticks that the current item has been cooking. 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 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...
 

Detailed Description

Definition at line 18 of file FurnaceEntity.h.

Member Typedef Documentation

◆ Super

Definition at line 23 of file FurnaceEntity.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
fsInput 
fsFuel 
fsOutput 
ContentsWidth 
ContentsHeight 

Definition at line 29 of file FurnaceEntity.h.

Constructor & Destructor Documentation

◆ cFurnaceEntity()

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

Constructor used for normal operation.

Definition at line 25 of file FurnaceEntity.cpp.

Member Function Documentation

◆ BroadcastProgress()

void cFurnaceEntity::BroadcastProgress ( size_t  a_ProgressbarID,
short  a_Value 
)
protected

Sends the specified progressbar value to all clients of the window.

Definition at line 183 of file FurnaceEntity.cpp.

◆ BurnNewFuel()

void cFurnaceEntity::BurnNewFuel ( void  )
protected

Starts burning a new fuel, if possible.

Definition at line 216 of file FurnaceEntity.cpp.

◆ CanCookInputToOutput()

bool cFurnaceEntity::CanCookInputToOutput ( void  ) const
protected

Returns true if the input can be cooked into output and the item counts allow for another cooking operation.

Definition at line 355 of file FurnaceEntity.cpp.

◆ ContinueCooking()

bool cFurnaceEntity::ContinueCooking ( void  )

Restarts cooking Used after the furnace is loaded from storage to set up the internal variables so that cooking continues, if it was active Returns true if cooking.

Definition at line 155 of file FurnaceEntity.cpp.

◆ CopyFrom()

void cFurnaceEntity::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 43 of file FurnaceEntity.cpp.

◆ FinishOne()

void cFurnaceEntity::FinishOne ( )
protected

One item finished cooking.

Definition at line 196 of file FurnaceEntity.cpp.

◆ GetAndResetReward()

int cFurnaceEntity::GetAndResetReward ( void  )

Calculates, resets, and returns the experience reward in this furnace.

Definition at line 166 of file FurnaceEntity.cpp.

◆ GetCookTimeLeft()

int cFurnaceEntity::GetCookTimeLeft ( void  ) const
inline

Returns the time until the current item finishes cooking, in ticks.

Definition at line 80 of file FurnaceEntity.h.

◆ GetFuelBurnTimeLeft()

int cFurnaceEntity::GetFuelBurnTimeLeft ( void  ) const
inline

Returns the time until the current fuel is depleted, in ticks.

Definition at line 83 of file FurnaceEntity.h.

◆ GetFuelSlot()

const cItem& cFurnaceEntity::GetFuelSlot ( void  ) const
inline

Returns the item in the fuel slot.

Definition at line 62 of file FurnaceEntity.h.

◆ GetInputSlot()

const cItem& cFurnaceEntity::GetInputSlot ( void  ) const
inline

Returns the item in the input slot.

Definition at line 59 of file FurnaceEntity.h.

◆ GetOutputSlot()

const cItem& cFurnaceEntity::GetOutputSlot ( void  ) const
inline

Returns the item in the output slot.

Definition at line 65 of file FurnaceEntity.h.

◆ GetTimeCooked()

int cFurnaceEntity::GetTimeCooked ( void  ) const
inline

Returns the time that the current item has been cooking, in ticks.

Definition at line 77 of file FurnaceEntity.h.

◆ HasFuelTimeLeft()

bool cFurnaceEntity::HasFuelTimeLeft ( void  ) const
inline

Returns true if there's time left before the current fuel is depleted.

Definition at line 86 of file FurnaceEntity.h.

◆ OnRemoveFromWorld()

void cFurnaceEntity::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 62 of file FurnaceEntity.cpp.

◆ OnSlotChanged()

void cFurnaceEntity::OnSlotChanged ( cItemGrid a_ItemGrid,
int  a_SlotNum 
)
overrideprotectedvirtual

Called whenever a slot changes.

Reimplemented from cBlockEntityWithItems.

Definition at line 246 of file FurnaceEntity.cpp.

◆ SendTo()

void cFurnaceEntity::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 76 of file FurnaceEntity.cpp.

◆ SetBurnTimes()

void cFurnaceEntity::SetBurnTimes ( int  a_FuelBurnTime,
int  a_TimeBurned 
)
inline

Definition at line 93 of file FurnaceEntity.h.

◆ SetCookTimes()

void cFurnaceEntity::SetCookTimes ( int  a_NeedCookTime,
int  a_TimeCooked 
)
inline

Definition at line 99 of file FurnaceEntity.h.

◆ SetFuelSlot()

void cFurnaceEntity::SetFuelSlot ( const cItem a_Item)
inline

Sets the item in the fuel slot.

Definition at line 71 of file FurnaceEntity.h.

◆ SetInputSlot()

void cFurnaceEntity::SetInputSlot ( const cItem a_Item)
inline

Sets the item in the input slot.

Definition at line 68 of file FurnaceEntity.h.

◆ SetIsCooking()

void cFurnaceEntity::SetIsCooking ( bool  a_IsCooking)
protected

Sets the m_IsCooking variable, updates the furnace block type based on the value.

Definition at line 409 of file FurnaceEntity.cpp.

◆ SetLoading()

void cFurnaceEntity::SetLoading ( bool  a_IsLoading)
inline

Definition at line 105 of file FurnaceEntity.h.

◆ SetOutputSlot()

void cFurnaceEntity::SetOutputSlot ( const cItem a_Item)
inline

Sets the item in the output slot.

Definition at line 74 of file FurnaceEntity.h.

◆ Tick()

bool cFurnaceEntity::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 86 of file FurnaceEntity.cpp.

◆ UpdateFuel()

void cFurnaceEntity::UpdateFuel ( void  )
protected

Called when the fuel slot changes or when the fuel is spent, burns another piece of fuel if appropriate.

Definition at line 310 of file FurnaceEntity.cpp.

◆ UpdateInput()

void cFurnaceEntity::UpdateInput ( void  )
protected

Updates the recipe, based on the current input.

Definition at line 269 of file FurnaceEntity.cpp.

◆ UpdateOutput()

void cFurnaceEntity::UpdateOutput ( void  )
protected

Called when the output slot changes.

Definition at line 326 of file FurnaceEntity.cpp.

◆ UpdateProgressBars()

void cFurnaceEntity::UpdateProgressBars ( bool  a_ForceUpdate = false)
protected

Broadcasts progressbar updates, if needed.

Definition at line 389 of file FurnaceEntity.cpp.

◆ UsedBy()

bool cFurnaceEntity::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 128 of file FurnaceEntity.cpp.

Member Data Documentation

◆ m_CurrentRecipe

const cFurnaceRecipe::cRecipe* cFurnaceEntity::m_CurrentRecipe
protected

The recipe for the current input slot.

Definition at line 114 of file FurnaceEntity.h.

◆ m_FuelBurnTime

int cFurnaceEntity::m_FuelBurnTime
protected

Amount of ticks that the current fuel can burn (in total); zero if no fuel burning.

Definition at line 129 of file FurnaceEntity.h.

◆ m_IsCooking

bool cFurnaceEntity::m_IsCooking
protected

Set to true if the furnace is cooking an item.

Definition at line 120 of file FurnaceEntity.h.

◆ m_IsLoading

bool cFurnaceEntity::m_IsLoading
protected

Is the block currently being loaded into the world?

Definition at line 138 of file FurnaceEntity.h.

◆ m_LastInput

cItem cFurnaceEntity::m_LastInput
protected

The item that is being smelted.

Definition at line 117 of file FurnaceEntity.h.

◆ m_NeedCookTime

int cFurnaceEntity::m_NeedCookTime
protected

Amount of ticks needed to fully cook current item.

Definition at line 123 of file FurnaceEntity.h.

◆ m_RewardCounter

float cFurnaceEntity::m_RewardCounter
protected

Running total of experience that can be picked up.

Definition at line 135 of file FurnaceEntity.h.

◆ m_TimeBurned

int cFurnaceEntity::m_TimeBurned
protected

Amount of ticks that the current fuel has been burning.

Definition at line 132 of file FurnaceEntity.h.

◆ m_TimeCooked

int cFurnaceEntity::m_TimeCooked
protected

Amount of ticks that the current item has been cooking.

Definition at line 126 of file FurnaceEntity.h.


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