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... | |
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 | 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... | |
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) |
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 |
cWorld * | GetWorld () 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 () | |
cWindow * | GetWindow (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::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_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 |
cWorld * | m_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... | |
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.
|
protected |
Sends the specified progressbar value to all clients of the window.
Definition at line 183 of file FurnaceEntity.cpp.
|
protected |
Starts burning a new fuel, if possible.
Definition at line 216 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 355 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 155 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 43 of file FurnaceEntity.cpp.
|
protected |
One item finished cooking.
Definition at line 196 of file FurnaceEntity.cpp.
int cFurnaceEntity::GetAndResetReward | ( | void | ) |
Calculates, resets, and returns the experience reward in this furnace.
Definition at line 166 of file FurnaceEntity.cpp.
|
inline |
Returns the time until the current item finishes cooking, in ticks.
Definition at line 80 of file FurnaceEntity.h.
|
inline |
Returns the time until the current fuel is depleted, in ticks.
Definition at line 83 of file FurnaceEntity.h.
|
inline |
Returns the item in the fuel slot.
Definition at line 62 of file FurnaceEntity.h.
|
inline |
Returns the item in the input slot.
Definition at line 59 of file FurnaceEntity.h.
|
inline |
Returns the item in the output slot.
Definition at line 65 of file FurnaceEntity.h.
|
inline |
Returns the time that the current item has been cooking, in ticks.
Definition at line 77 of file FurnaceEntity.h.
|
inline |
Returns true if there's time left before the current fuel is depleted.
Definition at line 86 of file FurnaceEntity.h.
|
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.
|
overrideprotectedvirtual |
Called whenever a slot changes.
Reimplemented from cBlockEntityWithItems.
Definition at line 246 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 76 of file FurnaceEntity.cpp.
|
inline |
Definition at line 93 of file FurnaceEntity.h.
|
inline |
Definition at line 99 of file FurnaceEntity.h.
|
inline |
Sets the item in the fuel slot.
Definition at line 71 of file FurnaceEntity.h.
|
inline |
Sets the item in the input slot.
Definition at line 68 of file FurnaceEntity.h.
|
protected |
Sets the m_IsCooking variable, updates the furnace block type based on the value.
Definition at line 409 of file FurnaceEntity.cpp.
|
inline |
Definition at line 105 of file FurnaceEntity.h.
|
inline |
Sets the item in the output slot.
Definition at line 74 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 86 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 310 of file FurnaceEntity.cpp.
|
protected |
Updates the recipe, based on the current input.
Definition at line 269 of file FurnaceEntity.cpp.
|
protected |
Called when the output slot changes.
Definition at line 326 of file FurnaceEntity.cpp.
|
protected |
Broadcasts progressbar updates, if needed.
Definition at line 389 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 128 of file FurnaceEntity.cpp.
|
protected |
The recipe for the current input slot.
Definition at line 114 of file FurnaceEntity.h.
|
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.
|
protected |
Set to true if the furnace is cooking an item.
Definition at line 120 of file FurnaceEntity.h.
|
protected |
Is the block currently being loaded into the world?
Definition at line 138 of file FurnaceEntity.h.
|
protected |
The item that is being smelted.
Definition at line 117 of file FurnaceEntity.h.
|
protected |
Amount of ticks needed to fully cook current item.
Definition at line 123 of file FurnaceEntity.h.
|
protected |
Running total of experience that can be picked up.
Definition at line 135 of file FurnaceEntity.h.
|
protected |
Amount of ticks that the current fuel has been burning.
Definition at line 132 of file FurnaceEntity.h.
|
protected |
Amount of ticks that the current item has been cooking.
Definition at line 126 of file FurnaceEntity.h.