From 487f9a2aa9b5497495cef1ac3b9c7a603e69f862 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 21 Apr 2020 22:19:22 +0200 Subject: Vector3 in Handlers (#4680) Refactored all cBlockHandler and cItemHandler descendants to use Vector3. --- src/Items/ItemArmor.h | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'src/Items/ItemArmor.h') diff --git a/src/Items/ItemArmor.h b/src/Items/ItemArmor.h index d218c22b3..d91888d5b 100644 --- a/src/Items/ItemArmor.h +++ b/src/Items/ItemArmor.h @@ -8,43 +8,52 @@ -class cItemArmorHandler : +class cItemArmorHandler: public cItemHandler { + using Super = cItemHandler; + public: - cItemArmorHandler(int a_ItemType) : - cItemHandler(a_ItemType) + + cItemArmorHandler(int a_ItemType): + Super(a_ItemType) { } + + /** Move the armor to the armor slot of the player's inventory */ virtual bool OnItemUse( - cWorld * a_World, cPlayer * a_Player, cBlockPluginInterface & a_PluginInterface, const cItem & a_Item, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace + cWorld * a_World, + cPlayer * a_Player, + cBlockPluginInterface & a_PluginInterface, + const cItem & a_HeldItem, + const Vector3i a_ClickedBlockPos, + eBlockFace a_ClickedBlockFace ) override { int SlotNum; - if (ItemCategory::IsHelmet(a_Item.m_ItemType)) + if (ItemCategory::IsHelmet(a_HeldItem.m_ItemType)) { SlotNum = 0; } - else if (ItemCategory::IsChestPlate(a_Item.m_ItemType)) + else if (ItemCategory::IsChestPlate(a_HeldItem.m_ItemType)) { SlotNum = 1; } - else if (ItemCategory::IsLeggings(a_Item.m_ItemType)) + else if (ItemCategory::IsLeggings(a_HeldItem.m_ItemType)) { SlotNum = 2; } - else if (ItemCategory::IsBoots(a_Item.m_ItemType)) + else if (ItemCategory::IsBoots(a_HeldItem.m_ItemType)) { SlotNum = 3; } else { - LOGWARNING("Used unknown armor: %i", a_Item.m_ItemType); + LOGWARNING("Used unknown armor: %i", a_HeldItem.m_ItemType); return false; } @@ -53,9 +62,9 @@ public: return false; } - a_Player->GetInventory().SetArmorSlot(SlotNum, a_Item.CopyOne()); + a_Player->GetInventory().SetArmorSlot(SlotNum, a_HeldItem.CopyOne()); - cItem Item(a_Item); + cItem Item(a_HeldItem); Item.m_ItemCount--; if (Item.m_ItemCount <= 0) { @@ -67,6 +76,8 @@ public: + + virtual bool CanRepairWithRawMaterial(short a_ItemType) override { switch (m_ItemType) -- cgit v1.2.3