Cuberite
A lightweight, fast and extensible game server for Minecraft
BrewingstandWindow.cpp
Go to the documentation of this file.
1 
2 // BrewingstandWindow.cpp
3 
4 // Representing the UI window for the brewing stand block
5 
6 #include "Globals.h"
7 #include "BrewingstandWindow.h"
8 #include "SlotArea.h"
9 #include "../BrewingRecipes.h"
10 #include "../Root.h"
11 
12 
13 
14 
15 
17  Super(wtBrewery, "Brewingstand")
18 {
19  m_SlotAreas.push_back(new cSlotAreaBrewingstand(a_Brewingstand, *this));
20  m_SlotAreas.push_back(new cSlotAreaInventory(*this));
21  m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
22 }
23 
24 
25 
26 
27 
28 void cBrewingstandWindow::DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply)
29 {
30  cSlotAreas AreasInOrder;
31 
32  if (a_ClickedArea == m_SlotAreas[0])
33  {
34  if ((a_Slot >= 0) && (a_Slot <= 4))
35  {
36  // Brewing stand Area
37  AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
38  AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
39  Super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
40  }
41  else
42  {
43  AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
44  AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
45  Super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
46  }
47  }
48  else
49  {
51  if ((BR->IsBottle(a_ItemStack)) || (BR->IsIngredient(a_ItemStack)) || BR->IsFuel(a_ItemStack))
52  {
53  AreasInOrder.push_back(m_SlotAreas[0]); /* brewing stand Area */
54  }
55  else if (a_ClickedArea == m_SlotAreas[1])
56  {
57  // Inventory Area
58  AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
59  }
60  else
61  {
62  // Hotbar Area
63  AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
64  }
65 
66  Super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
67  }
68 }
std::vector< cSlotArea * > cSlotAreas
Definition: Window.h:34
bool IsIngredient(const cItem &a_Ingredient) const
Returns true if the item is a ingredient, false if not.
bool IsBottle(const cItem &a_Item) const
Returns true if the item is a bottle / potion, false if not.
bool IsFuel(const cItem &a_Item) const
Returns true if the item is the fuel, false if not.
Definition: Player.h:29
Definition: Item.h:37
static cRoot * Get()
Definition: Root.h:52
cBrewingRecipes * GetBrewingRecipes(void)
Definition: Root.h:95
virtual void DistributeStack(cItem &a_ItemStack, int a_Slot, cPlayer &a_Player, cSlotArea *a_ClickedArea, bool a_ShouldApply) override
Called on shift-clicking to distribute the stack into other areas; Modifies a_ItemStack as it is dist...
cBrewingstandWindow(cBrewingstandEntity *a_Brewingstand)
Handles the main inventory of each player, excluding the armor and hotbar.
Definition: SlotArea.h:120
Handles the hotbar of each player.
Definition: SlotArea.h:138
Represents a UI window.
Definition: Window.h:54
void DistributeStackToAreas(cItem &a_ItemStack, cPlayer &a_Player, cSlotAreas &a_AreasInOrder, bool a_ShouldApply, bool a_BackFill)
Called from DistributeStack() to distribute the stack into a_AreasInOrder; Modifies a_ItemStack as it...
Definition: Window.cpp:467
cSlotAreas m_SlotAreas
Definition: Window.h:179