Cuberite
A lightweight, fast and extensible game server for Minecraft
MinecartWithChestWindow.h
Go to the documentation of this file.
1 
2 // MinecartWithChestWindow.h
3 
4 // Representing the UI window for the minecart chest entity
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "Window.h"
13 #include "../Entities/Minecart.h"
14 
15 
16 
17 
18 
20  public cWindow
21 {
22  typedef cWindow super;
23 
24 public:
26  cWindow(wtChest, "Minecart with Chest"),
27  m_ChestCart(a_ChestCart)
28  {
29  m_SlotAreas.push_back(new cSlotAreaMinecartWithChest(a_ChestCart, *this));
30  m_SlotAreas.push_back(new cSlotAreaInventory(*this));
31  m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
32 
33  a_ChestCart->GetWorld()->BroadcastSoundEffect("block.chest.open", a_ChestCart->GetPosition(), 1, 1);
34  }
35 
36  virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply) override
37  {
38  cSlotAreas AreasInOrder;
39 
40  if (a_ClickedArea == m_SlotAreas[0])
41  {
42  // Chest Area
43  AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
44  AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
45  super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
46  }
47  else
48  {
49  // Hotbar or Inventory
50  AreasInOrder.push_back(m_SlotAreas[0]); /* Chest */
51  super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
52  }
53  }
54 
55 
56  virtual ~cMinecartWithChestWindow() override
57  {
58  m_ChestCart->GetWorld()->BroadcastSoundEffect("block.chest.close", m_ChestCart->GetPosition(), 1, 1);
59  }
60 
61 private:
63 };
64 
65 
66 
67 
Handles the main inventory of each player, excluding the armor and hotbar.
Definition: SlotArea.h:117
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
cMinecartWithChestWindow(cMinecartWithChest *a_ChestCart)
virtual void BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr) override
std::vector< cSlotArea * > cSlotAreas
Definition: Window.h:34
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...
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
Definition: Entity.h:307
Represents a UI window.
Definition: Window.h:53
cMinecartWithChest * m_ChestCart
cSlotAreas m_SlotAreas
Definition: Window.h:182
virtual ~cMinecartWithChestWindow() override
Handles the hotbar of each player.
Definition: SlotArea.h:134
Definition: Item.h:36
cWorld * GetWorld(void) const
Definition: Entity.h:201