2015-03-10 14:40:53 -04: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 08:59:24 -04:00
|
|
|
cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest):
|
2015-03-10 14:40:53 -04:00
|
|
|
cWindow(wtChest, "Ender Chest"),
|
|
|
|
m_World(a_EnderChest->GetWorld()),
|
2017-09-19 10:12:54 -04:00
|
|
|
m_BlockPos(a_EnderChest->GetPos())
|
2015-03-10 14:40:53 -04: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 07:56:56 -04:00
|
|
|
m_World->BroadcastSoundEffect(
|
2017-02-15 00:05:24 -05:00
|
|
|
"block.enderchest.open",
|
2017-09-19 10:12:54 -04:00
|
|
|
m_BlockPos,
|
2015-05-28 07:29:26 -04:00
|
|
|
1,
|
|
|
|
1
|
|
|
|
);
|
2015-03-10 14:40:53 -04:00
|
|
|
|
|
|
|
// Send out the chest-open packet:
|
2017-09-19 10:12:54 -04:00
|
|
|
m_World->BroadcastBlockAction(m_BlockPos, 1, 1, E_BLOCK_ENDER_CHEST);
|
2015-03-10 14:40:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cEnderChestWindow::~cEnderChestWindow()
|
|
|
|
{
|
|
|
|
// Send out the chest-close packet:
|
2017-09-19 10:12:54 -04:00
|
|
|
m_World->BroadcastBlockAction(m_BlockPos, 1, 0, E_BLOCK_ENDER_CHEST);
|
2015-03-10 14:40:53 -04:00
|
|
|
|
|
|
|
// Play the closing sound
|
2015-05-24 07:56:56 -04:00
|
|
|
m_World->BroadcastSoundEffect(
|
2017-02-15 00:05:24 -05:00
|
|
|
"block.enderchest.close",
|
2017-09-19 10:12:54 -04:00
|
|
|
m_BlockPos,
|
2015-05-28 07:29:26 -04:00
|
|
|
1, 1
|
|
|
|
);
|
2015-03-10 14:40:53 -04: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 12:38:06 -04:00
|
|
|
Super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
|
2015-03-10 14:40:53 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Hotbar or Inventory
|
|
|
|
AreasInOrder.push_back(m_SlotAreas[0]); /* Chest */
|
2020-04-13 12:38:06 -04:00
|
|
|
Super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
|
2015-03-10 14:40:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|