2015-09-24 04:48:33 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BlockEntityWithItems.h"
|
|
|
|
#include "../BrewingRecipes.h"
|
|
|
|
#include "../Root.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-02 08:50:34 -05:00
|
|
|
|
2015-09-24 04:48:33 -04:00
|
|
|
class cClientHandle;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
class cBrewingstandEntity :
|
|
|
|
public cBlockEntityWithItems
|
|
|
|
{
|
2019-09-29 08:59:24 -04:00
|
|
|
// tolua_end
|
|
|
|
|
2020-04-13 12:38:06 -04:00
|
|
|
using Super = cBlockEntityWithItems;
|
2019-09-29 08:59:24 -04:00
|
|
|
|
|
|
|
// tolua_begin
|
2015-09-24 04:48:33 -04:00
|
|
|
|
|
|
|
public:
|
2019-09-29 08:59:24 -04:00
|
|
|
|
2015-09-24 04:48:33 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
bsLeftBottle = 0, // Left bottle slot number
|
|
|
|
bsMiddleBottle = 1, // Middle bottle slot number
|
|
|
|
bsRightBottle = 2, // Right bottle slot number
|
|
|
|
bsIngredient = 3, // Top ingredient slot number
|
2017-05-05 05:58:21 -04:00
|
|
|
bsFuel = 4, // Top left fuel slot number
|
2015-09-24 04:48:33 -04:00
|
|
|
|
2017-05-05 05:58:21 -04:00
|
|
|
ContentsWidth = 5,
|
2015-09-24 04:48:33 -04:00
|
|
|
ContentsHeight = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
// tolua_end
|
|
|
|
|
|
|
|
/** Constructor used for normal operation */
|
2019-09-29 08:59:24 -04:00
|
|
|
cBrewingstandEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World);
|
2015-09-24 04:48:33 -04:00
|
|
|
|
2021-01-02 08:50:34 -05:00
|
|
|
// cBlockEntity overrides:
|
2017-06-15 09:32:33 -04:00
|
|
|
virtual void CopyFrom(const cBlockEntity & a_Src) override;
|
2021-01-02 08:50:34 -05:00
|
|
|
virtual void OnRemoveFromWorld() override;
|
2015-09-24 04:48:33 -04:00
|
|
|
virtual void SendTo(cClientHandle & a_Client) override;
|
|
|
|
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
2015-12-01 17:12:44 -05:00
|
|
|
virtual bool UsedBy(cPlayer * a_Player) override;
|
2015-09-24 04:48:33 -04:00
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
|
|
|
|
/** Returns the time until the current items finishes brewing, in ticks */
|
|
|
|
short GetBrewingTimeLeft(void) const { return m_NeedBrewingTime - m_TimeBrewed; }
|
|
|
|
|
|
|
|
/** Returns the time that the current items has been brewing, in ticks */
|
|
|
|
short GetTimeBrewed(void) { return m_TimeBrewed; }
|
|
|
|
|
2017-05-05 05:58:21 -04:00
|
|
|
/** Returns the remaining fuel that is left. */
|
|
|
|
short GetRemainingFuel(void) { return m_RemainingFuel; }
|
|
|
|
|
2015-09-24 04:48:33 -04:00
|
|
|
/** Returns the item in the left bottle slot */
|
|
|
|
const cItem & GetLeftBottleSlot(void) const { return GetSlot(bsLeftBottle); }
|
|
|
|
|
|
|
|
/** Returns the item in the middle bottle slot */
|
|
|
|
const cItem & GetMiddleBottleSlot(void) const { return GetSlot(bsMiddleBottle); }
|
|
|
|
|
|
|
|
/** Returns the item in the right bottle slot */
|
|
|
|
const cItem & GetRightBottleSlot(void) const { return GetSlot(bsRightBottle); }
|
|
|
|
|
|
|
|
/** Returns the item in the ingredient slot */
|
|
|
|
const cItem & GetIndgredientSlot(void) const { return GetSlot(bsIngredient); }
|
|
|
|
|
2017-05-05 05:58:21 -04:00
|
|
|
/** Returns the item in the fuel slot. */
|
|
|
|
const cItem & GetFuelSlot(void) const { return GetSlot(bsFuel); }
|
|
|
|
|
2015-09-24 04:48:33 -04:00
|
|
|
/** Get the expected result item for the given slot number */
|
|
|
|
const cItem & GetResultItem(int a_SlotNumber) { return m_Results[a_SlotNumber]; }
|
|
|
|
|
|
|
|
/** Sets the item in the left bottle slot */
|
|
|
|
void SetLeftBottleSlot(const cItem & a_Item) { SetSlot(bsLeftBottle, a_Item); }
|
|
|
|
|
|
|
|
/** Sets the item in the middle bottle slot */
|
|
|
|
void SetMiddleBottleSlot(const cItem & a_Item) { SetSlot(bsMiddleBottle, a_Item); }
|
|
|
|
|
|
|
|
/** Sets the item in the right bottle slot */
|
|
|
|
void SetRightBottleSlot(const cItem & a_Item) { SetSlot(bsRightBottle, a_Item); }
|
|
|
|
|
|
|
|
/** Sets the item in the ingredient slot */
|
|
|
|
void SetIngredientSlot(const cItem & a_Item) { SetSlot(bsIngredient, a_Item); }
|
|
|
|
|
2017-05-05 05:58:21 -04:00
|
|
|
/** Sets the item in the fuel slot */
|
|
|
|
void SetFuelSlot(const cItem & a_Item) { SetSlot(bsFuel, a_Item); }
|
|
|
|
|
2015-09-24 04:48:33 -04:00
|
|
|
// tolua_end
|
|
|
|
|
|
|
|
/** Sets the current brewing time. Will be called if the brewing stand gets loaded from the world. */
|
2017-05-05 05:58:21 -04:00
|
|
|
void SetTimeBrewed(short a_TimeBrewed) { m_TimeBrewed = a_TimeBrewed; }
|
|
|
|
|
|
|
|
/** Sets the remaining fuel. Will be called if the brewing stand gets loaded from the world. */
|
|
|
|
void SetRemainingFuel(short a_RemainingFuel) { m_RemainingFuel = a_RemainingFuel; }
|
2015-09-24 04:48:33 -04:00
|
|
|
|
|
|
|
/** Starts the brewing proccess. Will be called if the brewing stand gets loaded from the world. */
|
|
|
|
void ContinueBrewing(void);
|
|
|
|
|
|
|
|
/** Gets the recipes. Will be called if the brewing stand gets loaded from the world. */
|
2017-05-05 05:58:21 -04:00
|
|
|
void LoadRecipes(void);
|
2015-09-24 04:48:33 -04:00
|
|
|
|
2017-06-15 09:32:33 -04:00
|
|
|
protected:
|
2015-09-24 04:48:33 -04:00
|
|
|
|
|
|
|
/** Set to true if the brewing stand is brewing an item */
|
|
|
|
bool m_IsBrewing;
|
|
|
|
|
|
|
|
/** Brewing time is 400 ticks */
|
|
|
|
const short m_NeedBrewingTime = 400;
|
|
|
|
|
|
|
|
/** Store the current brewing recipes */
|
|
|
|
const cBrewingRecipes::cRecipe * m_CurrentBrewingRecipes[3] = {};
|
|
|
|
|
|
|
|
/** Result items for the bottle inputs */
|
2017-06-15 09:32:33 -04:00
|
|
|
cItem m_Results[3];
|
2015-09-24 04:48:33 -04:00
|
|
|
|
|
|
|
/** Amount of ticks that the current item has been brewed */
|
|
|
|
short m_TimeBrewed;
|
|
|
|
|
2017-05-05 05:58:21 -04:00
|
|
|
/** The remaining fuel for the brewing stand. It's the amount of brewing operations that can be done. */
|
|
|
|
short m_RemainingFuel;
|
|
|
|
|
2015-09-24 04:48:33 -04:00
|
|
|
/** Sends the specified progressbar value to all clients of the window */
|
2020-10-02 09:22:17 -04:00
|
|
|
void BroadcastProgress(size_t a_ProgressbarID, short a_Value);
|
2015-09-24 04:48:33 -04:00
|
|
|
|
|
|
|
// /** Broadcasts progressbar updates, if needed */
|
|
|
|
void UpdateProgressBars(bool a_ForceUpdate = false);
|
|
|
|
|
|
|
|
// cItemGrid::cListener overrides:
|
|
|
|
virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
|
|
|
|
} ; // tolua_export
|