diff options
Diffstat (limited to 'src/UI')
-rw-r--r-- | src/UI/AnvilWindow.cpp | 17 | ||||
-rw-r--r-- | src/UI/AnvilWindow.h | 6 | ||||
-rw-r--r-- | src/UI/CraftingWindow.cpp | 2 | ||||
-rw-r--r-- | src/UI/CraftingWindow.h | 2 | ||||
-rw-r--r-- | src/UI/EnchantingWindow.cpp | 8 | ||||
-rw-r--r-- | src/UI/EnchantingWindow.h | 4 | ||||
-rw-r--r-- | src/UI/SlotArea.cpp | 18 | ||||
-rw-r--r-- | src/UI/SlotArea.h | 4 |
8 files changed, 21 insertions, 40 deletions
diff --git a/src/UI/AnvilWindow.cpp b/src/UI/AnvilWindow.cpp index 6d1d673df..66499cbc9 100644 --- a/src/UI/AnvilWindow.cpp +++ b/src/UI/AnvilWindow.cpp @@ -10,12 +10,10 @@ -cAnvilWindow::cAnvilWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : +cAnvilWindow::cAnvilWindow(Vector3i a_BlockPos) : cWindow(wtAnvil, "Repair"), m_RepairedItemName(""), - m_BlockX(a_BlockX), - m_BlockY(a_BlockY), - m_BlockZ(a_BlockZ) + m_BlockPos(a_BlockPos) { m_AnvilSlotArea = new cSlotAreaAnvil(*this); m_SlotAreas.push_back(m_AnvilSlotArea); @@ -49,17 +47,6 @@ void cAnvilWindow::SetRepairedItemName(const AString & a_Name, cPlayer * a_Playe -void cAnvilWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ) -{ - a_PosX = m_BlockX; - a_PosY = m_BlockY; - a_PosZ = m_BlockZ; -} - - - - - void cAnvilWindow::DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply) { cSlotAreas AreasInOrder; diff --git a/src/UI/AnvilWindow.h b/src/UI/AnvilWindow.h index 0b9a0e27e..be2ebc039 100644 --- a/src/UI/AnvilWindow.h +++ b/src/UI/AnvilWindow.h @@ -22,7 +22,7 @@ class cAnvilWindow: public: - cAnvilWindow(int a_BlockX, int a_BlockY, int a_BlockZ); + cAnvilWindow(Vector3i a_BlockPos); /** Gets the repaired item name. */ AString GetRepairedItemName(void) const; @@ -31,14 +31,14 @@ public: void SetRepairedItemName(const AString & a_Name, cPlayer * a_Player); /** Gets the Position from the Anvil */ - void GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ); + const Vector3i & GetBlockPos() { return m_BlockPos; } virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply) override; protected: cSlotAreaAnvil * m_AnvilSlotArea; AString m_RepairedItemName; - int m_BlockX, m_BlockY, m_BlockZ; + Vector3i m_BlockPos; }; diff --git a/src/UI/CraftingWindow.cpp b/src/UI/CraftingWindow.cpp index b5e7ec5a9..34599788c 100644 --- a/src/UI/CraftingWindow.cpp +++ b/src/UI/CraftingWindow.cpp @@ -10,7 +10,7 @@ -cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : +cCraftingWindow::cCraftingWindow() : cWindow(wtWorkbench, "Crafting Table") { m_SlotAreas.push_back(new cSlotAreaCrafting(3, *this)); diff --git a/src/UI/CraftingWindow.h b/src/UI/CraftingWindow.h index 2412bfdd7..75026dc67 100644 --- a/src/UI/CraftingWindow.h +++ b/src/UI/CraftingWindow.h @@ -22,7 +22,7 @@ class cCraftingWindow: public: - cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ); + cCraftingWindow(); virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply) override; }; diff --git a/src/UI/EnchantingWindow.cpp b/src/UI/EnchantingWindow.cpp index 3e0f2cd4c..a3abf3a02 100644 --- a/src/UI/EnchantingWindow.cpp +++ b/src/UI/EnchantingWindow.cpp @@ -11,14 +11,12 @@ -cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : +cEnchantingWindow::cEnchantingWindow(Vector3i a_BlockPos) : cWindow(wtEnchantment, "Enchant"), m_SlotArea(), - m_BlockX(a_BlockX), - m_BlockY(a_BlockY), - m_BlockZ(a_BlockZ) + m_BlockPos(a_BlockPos) { - m_SlotArea = new cSlotAreaEnchanting(*this, m_BlockX, m_BlockY, m_BlockZ); + m_SlotArea = new cSlotAreaEnchanting(*this, m_BlockPos); m_SlotAreas.push_back(m_SlotArea); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); diff --git a/src/UI/EnchantingWindow.h b/src/UI/EnchantingWindow.h index 61a40036f..5807d097e 100644 --- a/src/UI/EnchantingWindow.h +++ b/src/UI/EnchantingWindow.h @@ -22,7 +22,7 @@ class cEnchantingWindow: public: - cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ); + cEnchantingWindow(Vector3i a_BlockPos); virtual void SetProperty(short a_Property, short a_Value, cPlayer & a_Player) override; @@ -37,7 +37,7 @@ public: protected: short m_PropertyValue[3]; - int m_BlockX, m_BlockY, m_BlockZ; + Vector3i m_BlockPos; }; diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index cc662240b..0bbfb4b12 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -996,14 +996,12 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player) m_MaximumCost = 0; static_cast<cAnvilWindow &>(m_ParentWindow).SetRepairedItemName("", nullptr); - int PosX, PosY, PosZ; - static_cast<cAnvilWindow &>(m_ParentWindow).GetBlockPos(PosX, PosY, PosZ); + const Vector3i BlockPos = static_cast<cAnvilWindow &>(m_ParentWindow).GetBlockPos(); BLOCKTYPE Block; NIBBLETYPE BlockMeta; - a_Player.GetWorld()->GetBlockTypeMeta(PosX, PosY, PosZ, Block, BlockMeta); + a_Player.GetWorld()->GetBlockTypeMeta(BlockPos, Block, BlockMeta); - const Vector3i BlockPos{PosX, PosY, PosZ}; if (!a_Player.IsGameModeCreative() && (Block == E_BLOCK_ANVIL) && GetRandomProvider().RandBool(0.12)) { NIBBLETYPE Orientation = BlockMeta & 0x3; @@ -1013,13 +1011,13 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player) if (AnvilDamage > 2) { // Anvil will break - a_Player.GetWorld()->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, 0); + a_Player.GetWorld()->SetBlock(BlockPos, E_BLOCK_AIR, 0); a_Player.GetWorld()->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_ANVIL_BREAK, BlockPos, 0); a_Player.CloseWindow(false); } else { - a_Player.GetWorld()->SetBlockMeta(PosX, PosY, PosZ, static_cast<NIBBLETYPE>(Orientation | (AnvilDamage << 2))); + a_Player.GetWorld()->SetBlockMeta(BlockPos, static_cast<NIBBLETYPE>(Orientation | (AnvilDamage << 2))); a_Player.GetWorld()->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_ANVIL_USE, BlockPos, 0); } } @@ -1407,11 +1405,9 @@ void cSlotAreaBeacon::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) //////////////////////////////////////////////////////////////////////////////// // cSlotAreaEnchanting: -cSlotAreaEnchanting::cSlotAreaEnchanting(cWindow & a_ParentWindow, int a_BlockX, int a_BlockY, int a_BlockZ) : +cSlotAreaEnchanting::cSlotAreaEnchanting(cWindow & a_ParentWindow, Vector3i a_BlockPos) : cSlotAreaTemporary(2, a_ParentWindow), - m_BlockX(a_BlockX), - m_BlockY(a_BlockY), - m_BlockZ(a_BlockZ) + m_BlockPos(a_BlockPos) { } @@ -1644,7 +1640,7 @@ int cSlotAreaEnchanting::GetBookshelvesCount(cWorld & a_World) { int Bookshelves = 0; cBlockArea Area; - Area.Read(a_World, m_BlockX - 2, m_BlockX + 2, m_BlockY, m_BlockY + 1, m_BlockZ - 2, m_BlockZ + 2); + Area.Read(a_World, m_BlockPos - Vector3i(2, 0, 2), m_BlockPos + Vector3i(2, 1, 2)); static const struct { diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index a744fea2c..86c0afd51 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -381,7 +381,7 @@ class cSlotAreaEnchanting: public: - cSlotAreaEnchanting(cWindow & a_ParentWindow, int a_BlockX, int a_BlockY, int a_BlockZ); + cSlotAreaEnchanting(cWindow & a_ParentWindow, Vector3i a_BlockPos); // cSlotArea overrides: virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override; @@ -399,7 +399,7 @@ protected: /** Handles a click in the item slot. */ void UpdateResult(cPlayer & a_Player); - int m_BlockX, m_BlockY, m_BlockZ; + Vector3i m_BlockPos; }; |