From 30c8470a524f5d09f157d5c1c59eb72c205d5085 Mon Sep 17 00:00:00 2001 From: Lane Kolbly Date: Tue, 19 Sep 2017 09:12:54 -0500 Subject: Changed BroadcastSoundEffect, SendSoundEffect, and CastThunderbolt parameters to vectors (#3959) * Made BroadcastSoundEffect take vector parameters. * Added docs for new vectored methods * Removed old code * Fixed lua warnings * Made old BroadcastSoundEffect not an override. * m_Block to m_BlockPos, used Vector3d constructor where prettier. * a_Block to a_BlockPos * Changed thunderbolt a_Block to a_BlockPos --- src/UI/ChestWindow.cpp | 20 ++++++++------------ src/UI/ChestWindow.h | 2 +- src/UI/EnderChestWindow.cpp | 16 +++++----------- src/UI/EnderChestWindow.h | 2 +- src/UI/MinecartWithChestWindow.h | 4 ++-- 5 files changed, 17 insertions(+), 27 deletions(-) (limited to 'src/UI') diff --git a/src/UI/ChestWindow.cpp b/src/UI/ChestWindow.cpp index 7b3fe15af..67582b786 100644 --- a/src/UI/ChestWindow.cpp +++ b/src/UI/ChestWindow.cpp @@ -16,9 +16,7 @@ cChestWindow::cChestWindow(cChestEntity * a_Chest) : cWindow(wtChest, (a_Chest->GetBlockType() == E_BLOCK_CHEST) ? "Chest" : "Trapped Chest"), m_World(a_Chest->GetWorld()), - m_BlockX(a_Chest->GetPosX()), - m_BlockY(a_Chest->GetPosY()), - m_BlockZ(a_Chest->GetPosZ()), + m_BlockPos(a_Chest->GetPos()), m_PrimaryChest(a_Chest), m_SecondaryChest(nullptr) { @@ -27,10 +25,10 @@ cChestWindow::cChestWindow(cChestEntity * a_Chest) : m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); // Play the opening sound: - m_World->BroadcastSoundEffect("block.chest.open", static_cast(m_BlockX), static_cast(m_BlockY), static_cast(m_BlockZ), 1, 1); + m_World->BroadcastSoundEffect("block.chest.open", m_BlockPos, 1, 1); // Send out the chest-open packet: - m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_Chest->GetBlockType()); + m_World->BroadcastBlockAction(m_BlockPos, 1, 1, a_Chest->GetBlockType()); } @@ -40,9 +38,7 @@ cChestWindow::cChestWindow(cChestEntity * a_Chest) : cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_SecondaryChest) : cWindow(wtChest, (a_PrimaryChest->GetBlockType() == E_BLOCK_CHEST) ? "Double Chest" : "Double Trapped Chest"), m_World(a_PrimaryChest->GetWorld()), - m_BlockX(a_PrimaryChest->GetPosX()), - m_BlockY(a_PrimaryChest->GetPosY()), - m_BlockZ(a_PrimaryChest->GetPosZ()), + m_BlockPos(a_PrimaryChest->GetPos()), m_PrimaryChest(a_PrimaryChest), m_SecondaryChest(a_SecondaryChest) { @@ -51,10 +47,10 @@ cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_Secon m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); // Play the opening sound: - m_World->BroadcastSoundEffect("block.chest.open", static_cast(m_BlockX), static_cast(m_BlockY), static_cast(m_BlockZ), 1, 1); + m_World->BroadcastSoundEffect("block.chest.open", m_BlockPos, 1, 1); // Send out the chest-open packet: - m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_PrimaryChest->GetBlockType()); + m_World->BroadcastBlockAction(m_BlockPos, 1, 1, a_PrimaryChest->GetBlockType()); } @@ -64,9 +60,9 @@ cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_Secon cChestWindow::~cChestWindow() { // Send out the chest-close packet: - m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, m_PrimaryChest->GetBlockType()); + m_World->BroadcastBlockAction(m_BlockPos, 1, 0, m_PrimaryChest->GetBlockType()); - m_World->BroadcastSoundEffect("block.chest.close", static_cast(m_BlockX), static_cast(m_BlockY), static_cast(m_BlockZ), 1, 1); + m_World->BroadcastSoundEffect("block.chest.close", m_BlockPos, 1, 1); } diff --git a/src/UI/ChestWindow.h b/src/UI/ChestWindow.h index 8fe165920..932f7a2ec 100644 --- a/src/UI/ChestWindow.h +++ b/src/UI/ChestWindow.h @@ -35,7 +35,7 @@ public: protected: cWorld * m_World; - int m_BlockX, m_BlockY, m_BlockZ; // Position of the chest, for the window-close packet + Vector3i m_BlockPos; // Position of the chest, for the window-close packet cChestEntity * m_PrimaryChest; cChestEntity * m_SecondaryChest; }; diff --git a/src/UI/EnderChestWindow.cpp b/src/UI/EnderChestWindow.cpp index ed0fb499f..6c3bcff50 100644 --- a/src/UI/EnderChestWindow.cpp +++ b/src/UI/EnderChestWindow.cpp @@ -15,9 +15,7 @@ cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) : cWindow(wtChest, "Ender Chest"), m_World(a_EnderChest->GetWorld()), - m_BlockX(a_EnderChest->GetPosX()), - m_BlockY(a_EnderChest->GetPosY()), - m_BlockZ(a_EnderChest->GetPosZ()) + m_BlockPos(a_EnderChest->GetPos()) { m_SlotAreas.push_back(new cSlotAreaEnderChest(a_EnderChest, *this)); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); @@ -26,15 +24,13 @@ cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) : // Play the opening sound: m_World->BroadcastSoundEffect( "block.enderchest.open", - static_cast(m_BlockX), - static_cast(m_BlockY), - static_cast(m_BlockZ), + m_BlockPos, 1, 1 ); // Send out the chest-open packet: - m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_ENDER_CHEST); + m_World->BroadcastBlockAction(m_BlockPos, 1, 1, E_BLOCK_ENDER_CHEST); } @@ -44,14 +40,12 @@ cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) : cEnderChestWindow::~cEnderChestWindow() { // Send out the chest-close packet: - m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_ENDER_CHEST); + m_World->BroadcastBlockAction(m_BlockPos, 1, 0, E_BLOCK_ENDER_CHEST); // Play the closing sound m_World->BroadcastSoundEffect( "block.enderchest.close", - static_cast(m_BlockX), - static_cast(m_BlockY), - static_cast(m_BlockZ), + m_BlockPos, 1, 1 ); } diff --git a/src/UI/EnderChestWindow.h b/src/UI/EnderChestWindow.h index 05f8ca49f..b14c760e1 100644 --- a/src/UI/EnderChestWindow.h +++ b/src/UI/EnderChestWindow.h @@ -30,7 +30,7 @@ public: protected: cWorld * m_World; - int m_BlockX, m_BlockY, m_BlockZ; // Position of the enderchest, for the window-close packet + Vector3i m_BlockPos; // Position of the enderchest, for the window-close packet }; diff --git a/src/UI/MinecartWithChestWindow.h b/src/UI/MinecartWithChestWindow.h index 2ce728399..80d1ebfce 100644 --- a/src/UI/MinecartWithChestWindow.h +++ b/src/UI/MinecartWithChestWindow.h @@ -30,7 +30,7 @@ public: m_SlotAreas.push_back(new cSlotAreaInventory(*this)); m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); - a_ChestCart->GetWorld()->BroadcastSoundEffect("block.chest.open", a_ChestCart->GetPosX(), a_ChestCart->GetPosY(), a_ChestCart->GetPosZ(), 1, 1); + a_ChestCart->GetWorld()->BroadcastSoundEffect("block.chest.open", a_ChestCart->GetPosition(), 1, 1); } virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply) override @@ -55,7 +55,7 @@ public: virtual ~cMinecartWithChestWindow() override { - m_ChestCart->GetWorld()->BroadcastSoundEffect("block.chest.close", m_ChestCart->GetPosX(), m_ChestCart->GetPosY(), m_ChestCart->GetPosZ(), 1, 1); + m_ChestCart->GetWorld()->BroadcastSoundEffect("block.chest.close", m_ChestCart->GetPosition(), 1, 1); } private: -- cgit v1.2.3