summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemArmor.h
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-04-24 20:41:25 +0200
committerHowaner <franzi.moos@googlemail.com>2014-04-24 20:41:25 +0200
commit9cbb3a339f98f1737ea78af7f40e1ae7d25027e8 (patch)
tree34544dccfab33203ed5aed209199ba99df1b207d /src/Items/ItemArmor.h
parentUpdated docs for StringToEnchantmentID. (diff)
downloadcuberite-9cbb3a339f98f1737ea78af7f40e1ae7d25027e8.tar
cuberite-9cbb3a339f98f1737ea78af7f40e1ae7d25027e8.tar.gz
cuberite-9cbb3a339f98f1737ea78af7f40e1ae7d25027e8.tar.bz2
cuberite-9cbb3a339f98f1737ea78af7f40e1ae7d25027e8.tar.lz
cuberite-9cbb3a339f98f1737ea78af7f40e1ae7d25027e8.tar.xz
cuberite-9cbb3a339f98f1737ea78af7f40e1ae7d25027e8.tar.zst
cuberite-9cbb3a339f98f1737ea78af7f40e1ae7d25027e8.zip
Diffstat (limited to '')
-rw-r--r--src/Items/ItemArmor.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/Items/ItemArmor.h b/src/Items/ItemArmor.h
new file mode 100644
index 000000000..0f40ac443
--- /dev/null
+++ b/src/Items/ItemArmor.h
@@ -0,0 +1,54 @@
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+
+
+
+
+
+class cItemArmorHandler :
+ public cItemHandler
+{
+public:
+ cItemArmorHandler(int a_ItemType) :
+ cItemHandler(a_ItemType)
+ {
+ }
+
+ virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override
+ {
+ int SlotNum = -1;
+ if (ItemCategory::IsHelmet(a_Item.m_ItemType))
+ {
+ SlotNum = 0;
+ }
+ else if (ItemCategory::IsChestPlate(a_Item.m_ItemType))
+ {
+ SlotNum = 1;
+ }
+ else if (ItemCategory::IsLeggings(a_Item.m_ItemType))
+ {
+ SlotNum = 2;
+ }
+ else if (ItemCategory::IsBoots(a_Item.m_ItemType))
+ {
+ SlotNum = 3;
+ }
+
+ if (!a_Player->GetInventory().GetArmorSlot(SlotNum).IsEmpty())
+ {
+ return false;
+ }
+
+ a_Player->GetInventory().SetArmorSlot(SlotNum, a_Item.CopyOne());
+ a_Player->GetInventory().SetHotbarSlot(a_Player->GetInventory().GetEquippedSlotNum(), cItem());
+ return true;
+ }
+
+} ;
+
+
+
+