Cuberite
A lightweight, fast and extensible game server for Minecraft
HorseWindow.cpp
Go to the documentation of this file.
1 
2 // HorseWindow.cpp
3 
4 // Representing the UI window for a horse entity
5 
6 #include "Globals.h"
7 #include "../Mobs/Horse.h"
8 #include "../UI/HorseWindow.h"
9 #include "../UI/SlotArea.h"
10 
11 
12 
13 
14 
16  Super(wtAnimalChest, "Horse"),
17  m_Horse(a_Horse)
18 {
19  m_SlotAreas.push_back(new cSlotAreaHorse(a_Horse, *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 cHorseWindow::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  // Horse Area
35  AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
36  AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
37  Super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
38  }
39  else
40  {
41  // Inventory or Hotbar
42  if (ItemCategory::IsHorseArmor(a_ItemStack.m_ItemType) || (a_ItemStack.m_ItemType == E_ITEM_SADDLE))
43  {
44  AreasInOrder.push_back(m_SlotAreas[0]); /* Horse */
45  Super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
46  }
47  }
48 }
49 
50 
51 
52 
53 
55 {
56  return m_Horse.GetUniqueID();
57 }
58 
59 
60 
61 
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: HorseWindow.cpp:28
Handles the main inventory of each player, excluding the armor and hotbar.
Definition: SlotArea.h:117
cHorseWindow(cHorse &a_Horse)
Definition: HorseWindow.cpp:15
Slot area holding horse saddle and armor.
Definition: SlotArea.h:526
Definition: Player.h:27
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:401
Definition: Horse.h:11
cHorse & m_Horse
Definition: HorseWindow.h:29
UInt32 GetHorseID() const
Returns the horse's entity ID.
Definition: HorseWindow.cpp:54
std::vector< cSlotArea * > cSlotAreas
Definition: Window.h:34
bool IsHorseArmor(short a_ItemType)
Definition: Defines.h:1164
unsigned int UInt32
Definition: Globals.h:113
Represents a UI window.
Definition: Window.h:53
cSlotAreas m_SlotAreas
Definition: Window.h:182
short m_ItemType
Definition: Item.h:209
Handles the hotbar of each player.
Definition: SlotArea.h:134
Definition: Item.h:36
UInt32 GetUniqueID(void) const
Definition: Entity.h:261