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