2015-03-10 18:40:53 +00:00
|
|
|
|
|
|
|
// EnderChestWindow.cpp
|
|
|
|
|
|
|
|
// Representing the UI window for the enderchest block
|
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
#include "../World.h"
|
|
|
|
#include "EnderChestWindow.h"
|
|
|
|
#include "SlotArea.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-09-29 12:59:24 +00:00
|
|
|
cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest):
|
2015-03-10 18:40:53 +00:00
|
|
|
cWindow(wtChest, "Ender Chest"),
|
|
|
|
m_World(a_EnderChest->GetWorld()),
|
2017-09-19 14:12:54 +00:00
|
|
|
m_BlockPos(a_EnderChest->GetPos())
|
2015-03-10 18:40:53 +00:00
|
|
|
{
|
|
|
|
m_SlotAreas.push_back(new cSlotAreaEnderChest(a_EnderChest, *this));
|
|
|
|
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
|
|
|
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
|
|
|
|
|
|
|
// Play the opening sound:
|
2015-05-24 11:56:56 +00:00
|
|
|
m_World->BroadcastSoundEffect(
|
2017-02-15 05:05:24 +00:00
|
|
|
"block.enderchest.open",
|
2017-09-19 14:12:54 +00:00
|
|
|
m_BlockPos,
|
2015-05-28 11:29:26 +00:00
|
|
|
1,
|
|
|
|
1
|
|
|
|
);
|
2015-03-10 18:40:53 +00:00
|
|
|
|
|
|
|
// Send out the chest-open packet:
|
2017-09-19 14:12:54 +00:00
|
|
|
m_World->BroadcastBlockAction(m_BlockPos, 1, 1, E_BLOCK_ENDER_CHEST);
|
2015-03-10 18:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cEnderChestWindow::~cEnderChestWindow()
|
|
|
|
{
|
|
|
|
// Send out the chest-close packet:
|
2017-09-19 14:12:54 +00:00
|
|
|
m_World->BroadcastBlockAction(m_BlockPos, 1, 0, E_BLOCK_ENDER_CHEST);
|
2015-03-10 18:40:53 +00:00
|
|
|
|
|
|
|
// Play the closing sound
|
2015-05-24 11:56:56 +00:00
|
|
|
m_World->BroadcastSoundEffect(
|
2017-02-15 05:05:24 +00:00
|
|
|
"block.enderchest.close",
|
2017-09-19 14:12:54 +00:00
|
|
|
m_BlockPos,
|
2015-05-28 11:29:26 +00:00
|
|
|
1, 1
|
|
|
|
);
|
2015-03-10 18:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cEnderChestWindow::DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply)
|
|
|
|
{
|
|
|
|
cSlotAreas AreasInOrder;
|
|
|
|
|
|
|
|
if (a_ClickedArea == m_SlotAreas[0])
|
|
|
|
{
|
|
|
|
// Chest Area
|
|
|
|
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
|
|
|
|
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
|
2020-04-13 16:38:06 +00:00
|
|
|
Super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
|
2015-03-10 18:40:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Hotbar or Inventory
|
|
|
|
AreasInOrder.push_back(m_SlotAreas[0]); /* Chest */
|
2020-04-13 16:38:06 +00:00
|
|
|
Super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
|
2015-03-10 18:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|