summaryrefslogtreecommitdiffstats
path: root/src/Inventory.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-07-31 23:17:49 +0200
committermadmaxoft <github@xoft.cz>2014-07-31 23:17:49 +0200
commit6d02fce9a26d4272baea08dc58238321cca0183a (patch)
tree0109076ae52c67513259d7946a44b9f7b5a563fb /src/Inventory.cpp
parentRemoved trailing whitespace. (diff)
parentMerge pull request #1267 from mc-server/RoofedForest (diff)
downloadcuberite-6d02fce9a26d4272baea08dc58238321cca0183a.tar
cuberite-6d02fce9a26d4272baea08dc58238321cca0183a.tar.gz
cuberite-6d02fce9a26d4272baea08dc58238321cca0183a.tar.bz2
cuberite-6d02fce9a26d4272baea08dc58238321cca0183a.tar.lz
cuberite-6d02fce9a26d4272baea08dc58238321cca0183a.tar.xz
cuberite-6d02fce9a26d4272baea08dc58238321cca0183a.tar.zst
cuberite-6d02fce9a26d4272baea08dc58238321cca0183a.zip
Diffstat (limited to 'src/Inventory.cpp')
-rw-r--r--src/Inventory.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Inventory.cpp b/src/Inventory.cpp
index 3c2844612..8da3dea5f 100644
--- a/src/Inventory.cpp
+++ b/src/Inventory.cpp
@@ -226,12 +226,6 @@ void cInventory::SetSlot(int a_SlotNum, const cItem & a_Item)
return;
}
Grid->SetSlot(GridSlotNum, a_Item);
-
- // Broadcast the Equipped Item, if the Slot is changed.
- if ((Grid == &m_HotbarSlots) && (m_EquippedSlotNum == (a_SlotNum - invHotbarOffset)))
- {
- m_Owner.GetWorld()->BroadcastEntityEquipment(m_Owner, 0, a_Item, m_Owner.GetClientHandle());
- }
}
@@ -397,6 +391,10 @@ bool cInventory::DamageItem(int a_SlotNum, short a_Amount)
LOGWARNING("%s: requesting an invalid slot index: %d out of %d", __FUNCTION__, a_SlotNum, invNumSlots - 1);
return false;
}
+ if (a_Amount <= 0)
+ {
+ return false;
+ }
int GridSlotNum = 0;
cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum);
@@ -717,6 +715,12 @@ void cInventory::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
m_ArmorSlots.GetSlot(a_SlotNum), m_Owner.GetClientHandle()
);
}
+
+ // Broadcast the Equipped Item, if the Slot is changed.
+ if ((a_ItemGrid == &m_HotbarSlots) && (m_EquippedSlotNum == a_SlotNum))
+ {
+ m_Owner.GetWorld()->BroadcastEntityEquipment(m_Owner, 0, GetEquippedItem(), m_Owner.GetClientHandle());
+ }
// Convert the grid-local a_SlotNum to our global SlotNum:
int Base = 0;