5 #include "../UI/FurnaceWindow.h"
6 #include "../Entities/Player.h"
26 Super(a_BlockType, a_BlockMeta, a_Pos, ContentsWidth, ContentsHeight, a_World),
27 m_CurrentRecipe(nullptr),
65 if (Window !=
nullptr)
68 Window->OwnerDestroyed();
133 if (Window ==
nullptr)
139 if (Window !=
nullptr)
186 if (Window !=
nullptr)
261 default:
ASSERT(!
"Invalid furnace slot update!");
break;
@ PROGRESSBAR_SMELTING_CONFIRM
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
MTRand & GetRandomProvider()
Returns the current thread's random number source.
std::enable_if< std::is_arithmetic< T >::value, C >::type FloorC(T a_Value)
Floors a value, then casts it to C (an int by default).
BLOCKTYPE m_BlockType
The blocktype representing this particular instance in the world.
NIBBLETYPE m_BlockMeta
The block meta representing this particular instance in the world Mainly used for directional entitie...
Vector3i GetRelPos() const
Vector3i m_Pos
Position in absolute block coordinates.
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
virtual void OnSlotChanged(cItemGrid *a_Grid, int a_SlotNum) override
Called whenever a slot changes.
bool CanCookInputToOutput(void) const
Returns true if the input can be cooked into output and the item counts allow for another cooking ope...
int m_FuelBurnTime
Amount of ticks that the current fuel can burn (in total); zero if no fuel burning.
bool m_IsLoading
Is the block currently being loaded into the world?
void FinishOne()
One item finished cooking.
const cFurnaceRecipe::cRecipe * m_CurrentRecipe
The recipe for the current input slot.
virtual void OnRemoveFromWorld() override
Called when the block entity object is removed from a world.
bool m_IsCooking
Set to true if the furnace is cooking an item.
int GetFuelBurnTimeLeft(void) const
Returns the time until the current fuel is depleted, in ticks.
void UpdateOutput(void)
Called when the output slot changes.
virtual bool UsedBy(cPlayer *a_Player) override
Called when a player uses this entity; should open the UI window.
int m_NeedCookTime
Amount of ticks needed to fully cook current item.
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.
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
int m_TimeBurned
Amount of ticks that the current fuel has been burning.
cItem m_LastInput
The item that is being smelted.
cFurnaceEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
Constructor used for normal operation.
void SetIsCooking(bool a_IsCooking)
Sets the m_IsCooking variable, updates the furnace block type based on the value.
void UpdateInput(void)
Updates the recipe, based on the current input.
float m_RewardCounter
Running total of experience that can be picked up.
void SetBurnTimes(int a_FuelBurnTime, int a_TimeBurned)
void SetCookTimes(int a_NeedCookTime, int a_TimeCooked)
bool ContinueCooking(void)
Restarts cooking Used after the furnace is loaded from storage to set up the internal variables so th...
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
void BroadcastProgress(size_t a_ProgressbarID, short a_Value)
Sends the specified progressbar value to all clients of the window.
int m_TimeCooked
Amount of ticks that the current item has been cooking.
void UpdateFuel(void)
Called when the fuel slot changes or when the fuel is spent, burns another piece of fuel if appropria...
void BurnNewFuel(void)
Starts burning a new fuel, if possible.
virtual void SendTo(cClientHandle &a_Client) override
Sends the packet defining the block entity to the client specified.
int GetAndResetReward(void)
Calculates, resets, and returns the experience reward in this furnace.
void UpdateProgressBars(bool a_ForceUpdate=false)
Broadcasts progressbar updates, if needed.
void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
StatisticsManager & GetStatistics()
Return the associated statistic and achievement manager.
void OpenWindow(cWindow &a_Window)
Opens the specified window; closes the current one first using CloseWindow()
cWindow * GetWindow(void)
bool RandBool(double a_TrueProbability=0.5)
Return a random bool with the given probability of being true.
const cRecipe * GetRecipeFrom(const cItem &a_Ingredient) const
Returns a recipe for the specified input, nullptr if no recipe found.
int GetBurnTime(const cItem &a_Fuel) const
Returns the amount of time that the specified fuel burns, in ticks.
int CookTime
How long this recipe takes to smelt, in ticks.
float Reward
Experience reward for creating 1 of this item.
bool IsEmpty(void) const
Returns true if the item represents an empty stack - either the type is invalid, or count is zero.
bool IsEqual(const cItem &a_Item) const
bool IsFullStack(void) const
Returns true if the item is stacked up to its maximum stacking.
void CopyFrom(const cItemGrid &a_Src)
Copies all items from a_Src to this grid.
char ChangeSlotCount(int a_SlotNum, char a_AddToCount)
Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot.
void SetSlot(int a_X, int a_Y, const cItem &a_Item)
const cItem & GetSlot(int a_X, int a_Y) const
void AddListener(cListener &a_Listener)
Adds a callback that gets called whenever a slot changes.
cFurnaceRecipe * GetFurnaceRecipe(void)
std::unordered_map< CustomStatistic, StatValue > Custom
virtual void SetProperty(size_t a_Property, short a_Value)
Updates a numerical property associated with the window.
cWindow * GetWindow(void) const
void OpenWindow(cWindow *a_Window)
cTickTimeLong GetWorldTickAge() const
void FastSetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.