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 }
cBrewingstandWindow::DistributeStack
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...
Definition: BrewingstandWindow.cpp:28
cWindow::DistributeStackToAreas
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
cBrewingRecipes
Definition: BrewingRecipes.h:14
cWindow
Represents a UI window.
Definition: Window.h:53
cSlotAreaHotBar
Handles the hotbar of each player.
Definition: SlotArea.h:136
Globals.h
cBrewingRecipes::IsFuel
bool IsFuel(const cItem &a_Item) const
Returns true if the item is the fuel, false if not.
Definition: BrewingRecipes.cpp:229
cRoot::Get
static cRoot * Get()
Definition: Root.h:52
cWindow::m_SlotAreas
cSlotAreas m_SlotAreas
Definition: Window.h:179
cBrewingstandWindow::cBrewingstandWindow
cBrewingstandWindow(cBrewingstandEntity *a_Brewingstand)
Definition: BrewingstandWindow.cpp:16
cItem
Definition: Item.h:36
cSlotAreaBrewingstand
Definition: SlotArea.h:503
cBrewingRecipes::IsBottle
bool IsBottle(const cItem &a_Item) const
Returns true if the item is a bottle / potion, false if not.
Definition: BrewingRecipes.cpp:220
BrewingstandWindow.h
cSlotAreaInventory
Handles the main inventory of each player, excluding the armor and hotbar.
Definition: SlotArea.h:118
cPlayer
Definition: Player.h:27
cBrewingRecipes::IsIngredient
bool IsIngredient(const cItem &a_Ingredient) const
Returns true if the item is a ingredient, false if not.
Definition: BrewingRecipes.cpp:198
SlotArea.h
cSlotAreas
std::vector< cSlotArea * > cSlotAreas
Definition: Window.h:34
cBrewingstandEntity
Definition: BrewingstandEntity.h:19
cSlotArea
Definition: SlotArea.h:33
cRoot::GetBrewingRecipes
cBrewingRecipes * GetBrewingRecipes(void)
Definition: Root.h:95