summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-04-25 00:09:22 +0200
committerHowaner <franzi.moos@googlemail.com>2014-04-25 00:09:22 +0200
commitcee70390fae9c240337186e50445e50518ccdba8 (patch)
tree810305b0305aa022c0d90ee2e7e814c0bf099850
parentAdd armor to switch() in ItemHandler.cpp (diff)
downloadcuberite-cee70390fae9c240337186e50445e50518ccdba8.tar
cuberite-cee70390fae9c240337186e50445e50518ccdba8.tar.gz
cuberite-cee70390fae9c240337186e50445e50518ccdba8.tar.bz2
cuberite-cee70390fae9c240337186e50445e50518ccdba8.tar.lz
cuberite-cee70390fae9c240337186e50445e50518ccdba8.tar.xz
cuberite-cee70390fae9c240337186e50445e50518ccdba8.tar.zst
cuberite-cee70390fae9c240337186e50445e50518ccdba8.zip
-rw-r--r--src/Items/ItemArmor.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Items/ItemArmor.h b/src/Items/ItemArmor.h
index 0f40ac443..a786990fc 100644
--- a/src/Items/ItemArmor.h
+++ b/src/Items/ItemArmor.h
@@ -19,7 +19,7 @@ public:
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;
+ int SlotNum;
if (ItemCategory::IsHelmet(a_Item.m_ItemType))
{
SlotNum = 0;
@@ -36,6 +36,11 @@ public:
{
SlotNum = 3;
}
+ else
+ {
+ LOGWARNING("Used unknown armor: %i", a_Item.m_ItemType);
+ return false;
+ }
if (!a_Player->GetInventory().GetArmorSlot(SlotNum).IsEmpty())
{
@@ -43,7 +48,14 @@ public:
}
a_Player->GetInventory().SetArmorSlot(SlotNum, a_Item.CopyOne());
- a_Player->GetInventory().SetHotbarSlot(a_Player->GetInventory().GetEquippedSlotNum(), cItem());
+
+ cItem Item(a_Item);
+ Item.m_ItemCount--;
+ if (Item.m_ItemCount <= 0)
+ {
+ Item.Empty();
+ }
+ a_Player->GetInventory().SetHotbarSlot(a_Player->GetInventory().GetEquippedSlotNum(), Item);
return true;
}