diff options
author | MaxwellScroggs <66567983+MaxwellScroggs@users.noreply.github.com> | 2020-07-04 23:49:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-04 23:49:17 +0200 |
commit | 5cdaf073be015a99e87dde4540405a69ff56eb47 (patch) | |
tree | a8730b445ea9620a603f21008c583412d6775cf2 | |
parent | Merged trivial item handlers into cSimplePlaceableItemHandler (#4766) (diff) | |
download | cuberite-5cdaf073be015a99e87dde4540405a69ff56eb47.tar cuberite-5cdaf073be015a99e87dde4540405a69ff56eb47.tar.gz cuberite-5cdaf073be015a99e87dde4540405a69ff56eb47.tar.bz2 cuberite-5cdaf073be015a99e87dde4540405a69ff56eb47.tar.lz cuberite-5cdaf073be015a99e87dde4540405a69ff56eb47.tar.xz cuberite-5cdaf073be015a99e87dde4540405a69ff56eb47.tar.zst cuberite-5cdaf073be015a99e87dde4540405a69ff56eb47.zip |
-rw-r--r-- | CONTRIBUTORS | 1 | ||||
-rw-r--r-- | src/Blocks/BlockAnvil.h | 2 | ||||
-rw-r--r-- | src/Blocks/BlockEnchantmentTable.h | 2 | ||||
-rw-r--r-- | src/Blocks/BlockWorkbench.h | 2 | ||||
-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 |
12 files changed, 25 insertions, 43 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 37e1ca5bf..281ca6f74 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -38,6 +38,7 @@ maxluchterhand1 marmot21 Masy98 mathiascode +MaxwellScroggs mborland mBornand MeMuXin diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h index ad6d216cd..927d55786 100644 --- a/src/Blocks/BlockAnvil.h +++ b/src/Blocks/BlockAnvil.h @@ -44,7 +44,7 @@ public: const Vector3i a_CursorPos ) override { - cWindow * Window = new cAnvilWindow(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z); + cWindow * Window = new cAnvilWindow(a_BlockPos); a_Player.OpenWindow(*Window); return true; } diff --git a/src/Blocks/BlockEnchantmentTable.h b/src/Blocks/BlockEnchantmentTable.h index a981cf7a7..48560451b 100644 --- a/src/Blocks/BlockEnchantmentTable.h +++ b/src/Blocks/BlockEnchantmentTable.h @@ -34,7 +34,7 @@ public: const Vector3i a_CursorPos ) override { - cWindow * Window = new cEnchantingWindow(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z); + cWindow * Window = new cEnchantingWindow(a_BlockPos); a_Player.OpenWindow(*Window); return true; } diff --git a/src/Blocks/BlockWorkbench.h b/src/Blocks/BlockWorkbench.h index 608754158..19bf551dd 100644 --- a/src/Blocks/BlockWorkbench.h +++ b/src/Blocks/BlockWorkbench.h @@ -34,7 +34,7 @@ public: const Vector3i a_CursorPos ) override { - cWindow * Window = new cCraftingWindow(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z); + cWindow * Window = new cCraftingWindow(); a_Player.OpenWindow(*Window); return true; } 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; }; |