![]() |
Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <FurnaceEntity.h>
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... | |
virtual void | Destroy () override |
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 cItem & | GetFuelSlot (void) const |
Returns the item in the fuel slot. More... | |
const cItem & | GetInputSlot (void) const |
Returns the item in the input slot. More... | |
const cItem & | GetOutputSlot (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 | 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... | |
virtual | ~cFurnaceEntity () override |
![]() | |
cBlockEntityWithItems (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, int a_ItemGridWidth, int a_ItemGridHeight, cWorld *a_World) | |
cItemGrid & | GetContents (void) |
Returns the ItemGrid used for storing the contents. More... | |
const cItemGrid & | GetContents (void) const |
Const version of the GetContents() function for C++ type-safety. More... | |
const cItem & | GetSlot (int a_SlotNum) const |
const cItem & | GetSlot (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) |
![]() | |
cBlockEntity * | 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 |
virtual const char * | GetClass () const |
Returns the name of the topmost class (the most descendant). More... | |
virtual const char * | GetParentClass () const |
Returns the name of the parent class, or empty string if no parent class. More... | |
Vector3i | GetPos () const |
int | GetPosX () const |
int | GetPosY () const |
int | GetPosZ () const |
Vector3i | GetRelPos () const |
int | GetRelX () const |
int | GetRelZ () const |
cWorld * | GetWorld () const |
virtual bool | IsA (const char *a_ClassName) const |
Returns true if the object is the specified class, or its descendant. More... | |
void | SetPos (Vector3i a_NewPos) |
Updates the internally stored position. More... | |
void | SetWorld (cWorld *a_World) |
virtual | ~cBlockEntity () |
![]() | |
virtual | ~cListener () |
![]() | |
cBlockEntityWindowOwner (cBlockEntity *a_BlockEntity) | |
virtual Vector3i | GetBlockPos (void) override |
Returns the block position at which the element owning the window is. More... | |
![]() | |
void | CloseWindow (void) |
cWindowOwner () | |
cWindow * | GetWindow (void) const |
void | OpenWindow (cWindow *a_Window) |
virtual | ~cWindowOwner () |
Protected Member Functions | |
void | BroadcastProgress (short 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... | |
![]() | |
cBlockEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World) | |
Protected Attributes | |
const cFurnaceRecipe::cRecipe * | m_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_IsDestroyed |
Set to true when the furnace entity has been destroyed to prevent the block being set again. 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... | |
![]() | |
cItemGrid | m_Contents |
![]() | |
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 |
cWorld * | m_World |
Private Types | |
using | super = cBlockEntityWithItems |
Additional Inherited Members | |
![]() | |
static cBlockEntity * | 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 const char * | GetClassStatic () |
static bool | IsBlockEntityBlockType (BLOCKTYPE a_BlockType) |
Returns true if the specified blocktype is supposed to have an associated block entity. More... | |
Definition at line 18 of file FurnaceEntity.h.
|
private |
Definition at line 23 of file FurnaceEntity.h.
anonymous enum |
Enumerator | |
---|---|
fsInput | |
fsFuel | |
fsOutput | |
ContentsWidth | |
ContentsHeight |
Definition at line 29 of file FurnaceEntity.h.
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.
|
overridevirtual |
Definition at line 44 of file FurnaceEntity.cpp.
|
protected |
Sends the specified progressbar value to all clients of the window.
Definition at line 193 of file FurnaceEntity.cpp.
|
protected |
Starts burning a new fuel, if possible.
Definition at line 226 of file FurnaceEntity.cpp.
|
protected |
Returns true if the input can be cooked into output and the item counts allow for another cooking operation.
Definition at line 370 of file FurnaceEntity.cpp.
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 165 of file FurnaceEntity.cpp.
|
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 68 of file FurnaceEntity.cpp.
|
overridevirtual |
Reimplemented from cBlockEntityWithItems.
Definition at line 58 of file FurnaceEntity.cpp.
|
protected |
One item finished cooking.
Definition at line 206 of file FurnaceEntity.cpp.
int cFurnaceEntity::GetAndResetReward | ( | void | ) |
Calculates, resets, and returns the experience reward in this furnace.
Definition at line 176 of file FurnaceEntity.cpp.
|
inline |
Returns the time until the current item finishes cooking, in ticks.
Definition at line 84 of file FurnaceEntity.h.
|
inline |
Returns the time until the current fuel is depleted, in ticks.
Definition at line 87 of file FurnaceEntity.h.
|
inline |
Returns the item in the fuel slot.
Definition at line 66 of file FurnaceEntity.h.
|
inline |
Returns the item in the input slot.
Definition at line 63 of file FurnaceEntity.h.
|
inline |
Returns the item in the output slot.
Definition at line 69 of file FurnaceEntity.h.
|
inline |
Returns the time that the current item has been cooking, in ticks.
Definition at line 81 of file FurnaceEntity.h.
|
inline |
Returns true if there's time left before the current fuel is depleted.
Definition at line 90 of file FurnaceEntity.h.
|
overrideprotectedvirtual |
Called whenever a slot changes.
Reimplemented from cBlockEntityWithItems.
Definition at line 256 of file FurnaceEntity.cpp.
|
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 88 of file FurnaceEntity.cpp.
|
inline |
Definition at line 97 of file FurnaceEntity.h.
|
inline |
Definition at line 103 of file FurnaceEntity.h.
|
inline |
Sets the item in the fuel slot.
Definition at line 75 of file FurnaceEntity.h.
|
inline |
Sets the item in the input slot.
Definition at line 72 of file FurnaceEntity.h.
|
protected |
Sets the m_IsCooking variable, updates the furnace block type based on the value.
Definition at line 424 of file FurnaceEntity.cpp.
|
inline |
Definition at line 109 of file FurnaceEntity.h.
|
inline |
Sets the item in the output slot.
Definition at line 78 of file FurnaceEntity.h.
|
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 98 of file FurnaceEntity.cpp.
|
protected |
Called when the fuel slot changes or when the fuel is spent, burns another piece of fuel if appropriate.
Definition at line 325 of file FurnaceEntity.cpp.
|
protected |
Updates the recipe, based on the current input.
Definition at line 284 of file FurnaceEntity.cpp.
|
protected |
Called when the output slot changes.
Definition at line 341 of file FurnaceEntity.cpp.
|
protected |
Broadcasts progressbar updates, if needed.
Definition at line 404 of file FurnaceEntity.cpp.
|
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 140 of file FurnaceEntity.cpp.
|
protected |
The recipe for the current input slot.
Definition at line 118 of file FurnaceEntity.h.
|
protected |
Amount of ticks that the current fuel can burn (in total); zero if no fuel burning.
Definition at line 136 of file FurnaceEntity.h.
|
protected |
Set to true if the furnace is cooking an item.
Definition at line 127 of file FurnaceEntity.h.
|
protected |
Set to true when the furnace entity has been destroyed to prevent the block being set again.
Definition at line 124 of file FurnaceEntity.h.
|
protected |
Is the block currently being loaded into the world?
Definition at line 145 of file FurnaceEntity.h.
|
protected |
The item that is being smelted.
Definition at line 121 of file FurnaceEntity.h.
|
protected |
Amount of ticks needed to fully cook current item.
Definition at line 130 of file FurnaceEntity.h.
|
protected |
Running total of experience that can be picked up.
Definition at line 142 of file FurnaceEntity.h.
|
protected |
Amount of ticks that the current fuel has been burning.
Definition at line 139 of file FurnaceEntity.h.
|
protected |
Amount of ticks that the current item has been cooking.
Definition at line 133 of file FurnaceEntity.h.