Cuberite
A lightweight, fast and extensible game server for Minecraft
BrewingstandEntity.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockEntityWithItems.h"
5 #include "../BrewingRecipes.h"
6 #include "../Root.h"
7 
8 
9 
10 
11 class cClientHandle;
12 
13 
14 
15 
16 
17 // tolua_begin
20 {
21  // tolua_end
22 
24 
25  // tolua_begin
26 
27 public:
28 
29  enum
30  {
31  bsLeftBottle = 0, // Left bottle slot number
32  bsMiddleBottle = 1, // Middle bottle slot number
33  bsRightBottle = 2, // Right bottle slot number
34  bsIngredient = 3, // Top ingredient slot number
35  bsFuel = 4, // Top left fuel slot number
36 
39  };
40 
41  // tolua_end
42 
44 
45 
46  cBrewingstandEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World);
47 
48  virtual ~cBrewingstandEntity() override;
49 
50  // cBlockEntity overrides:
51  virtual void Destroy() override;
52  virtual void CopyFrom(const cBlockEntity & a_Src) override;
53  virtual void SendTo(cClientHandle & a_Client) override;
54  virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
55  virtual bool UsedBy(cPlayer * a_Player) override;
56 
57  // tolua_begin
58 
60  short GetBrewingTimeLeft(void) const { return m_NeedBrewingTime - m_TimeBrewed; }
61 
63  short GetTimeBrewed(void) { return m_TimeBrewed; }
64 
66  short GetRemainingFuel(void) { return m_RemainingFuel; }
67 
69  const cItem & GetLeftBottleSlot(void) const { return GetSlot(bsLeftBottle); }
70 
72  const cItem & GetMiddleBottleSlot(void) const { return GetSlot(bsMiddleBottle); }
73 
75  const cItem & GetRightBottleSlot(void) const { return GetSlot(bsRightBottle); }
76 
78  const cItem & GetIndgredientSlot(void) const { return GetSlot(bsIngredient); }
79 
81  const cItem & GetFuelSlot(void) const { return GetSlot(bsFuel); }
82 
84  const cItem & GetResultItem(int a_SlotNumber) { return m_Results[a_SlotNumber]; }
85 
87  void SetLeftBottleSlot(const cItem & a_Item) { SetSlot(bsLeftBottle, a_Item); }
88 
90  void SetMiddleBottleSlot(const cItem & a_Item) { SetSlot(bsMiddleBottle, a_Item); }
91 
93  void SetRightBottleSlot(const cItem & a_Item) { SetSlot(bsRightBottle, a_Item); }
94 
96  void SetIngredientSlot(const cItem & a_Item) { SetSlot(bsIngredient, a_Item); }
97 
99  void SetFuelSlot(const cItem & a_Item) { SetSlot(bsFuel, a_Item); }
100 
101  // tolua_end
102 
104  void SetTimeBrewed(short a_TimeBrewed) { m_TimeBrewed = a_TimeBrewed; }
105 
107  void SetRemainingFuel(short a_RemainingFuel) { m_RemainingFuel = a_RemainingFuel; }
108 
110  void ContinueBrewing(void);
111 
113  void LoadRecipes(void);
114 
115 
116 protected:
117 
120 
123 
125  const short m_NeedBrewingTime = 400;
126 
129 
132 
135 
138 
140  void BroadcastProgress(short a_ProgressbarID, short a_Value);
141 
142  // /** Broadcasts progressbar updates, if needed */
143  void UpdateProgressBars(bool a_ForceUpdate = false);
144 
145  // cItemGrid::cListener overrides:
146  virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
147 
148 } ; // tolua_export
149 
150 
151 
152 
153 
Definition: FastNBT.h:131
cItem m_Results[3]
Result items for the bottle inputs.
void SetMiddleBottleSlot(const cItem &a_Item)
Sets the item in the middle bottle slot.
void SetSlot(int a_SlotNum, const cItem &a_Item)
short GetTimeBrewed(void)
Returns the time that the current items has been brewing, in ticks.
cBlockEntityWithItems(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, int a_ItemGridWidth, int a_ItemGridHeight, cWorld *a_World)
virtual bool UsedBy(cPlayer *a_Player) override
Called when a player uses this entity; should open the UI window.
void UpdateProgressBars(bool a_ForceUpdate=false)
Broadcasts progressbar updates, if needed.
void SetTimeBrewed(short a_TimeBrewed)
Sets the current brewing time.
bool m_IsBrewing
Set to true if the brewing stand is brewing an item.
const cItem & GetIndgredientSlot(void) const
Returns the item in the ingredient slot.
short m_TimeBrewed
Amount of ticks that the current item has been brewed.
const cItem & GetMiddleBottleSlot(void) const
Returns the item in the middle bottle slot.
void SetIngredientSlot(const cItem &a_Item)
Sets the item in the ingredient slot.
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
const cItem & GetSlot(int a_SlotNum) const
void LoadRecipes(void)
Gets the recipes.
short m_RemainingFuel
The remaining fuel for the brewing stand.
Definition: Player.h:27
const cItem & GetFuelSlot(void) const
Returns the item in the fuel slot.
virtual void Destroy() override
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
Definition: Chunk.h:49
virtual void SendTo(cClientHandle &a_Client) override
Sends the packet defining the block entity to the client specified.
const cItem & GetResultItem(int a_SlotNumber)
Get the expected result item for the given slot number.
Definition: World.h:65
short GetRemainingFuel(void)
Returns the remaining fuel that is left.
void SetLeftBottleSlot(const cItem &a_Item)
Sets the item in the left bottle slot.
void SetRemainingFuel(short a_RemainingFuel)
Sets the remaining fuel.
bool m_IsDestroyed
Set to true when the brewing stand entity has been destroyed to prevent the block being set again...
void SetRightBottleSlot(const cItem &a_Item)
Sets the item in the right bottle slot.
const cBrewingRecipes::cRecipe * m_CurrentBrewingRecipes[3]
Store the current brewing recipes.
const cItem & GetRightBottleSlot(void) const
Returns the item in the right bottle slot.
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 & GetLeftBottleSlot(void) const
Returns the item in the left bottle slot.
void ContinueBrewing(void)
Starts the brewing proccess.
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
#define BLOCKENTITY_PROTODEF(classname)
Place this macro in the declaration of each cBlockEntity descendant.
Definition: BlockEntity.h:9
short GetBrewingTimeLeft(void) const
Returns the time until the current items finishes brewing, in ticks.
void BroadcastProgress(short a_ProgressbarID, short a_Value)
Sends the specified progressbar value to all clients of the window.
const short m_NeedBrewingTime
Brewing time is 400 ticks.
Definition: Item.h:36
void SetFuelSlot(const cItem &a_Item)
Sets the item in the fuel slot.
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...