summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-01-15 23:36:19 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-01-15 23:36:19 +0100
commit3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0 (patch)
treee307ee5d190723f9c4cd8294458f823a522dd6e8 /src/Entities/Player.cpp
parentMerge pull request #545 from mc-server/VarArgs (diff)
downloadcuberite-3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0.tar
cuberite-3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0.tar.gz
cuberite-3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0.tar.bz2
cuberite-3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0.tar.lz
cuberite-3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0.tar.xz
cuberite-3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0.tar.zst
cuberite-3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Player.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index fa6422389..22cbf656b 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1382,11 +1382,16 @@ void cPlayer::TossItem(
cItem DroppedItem(GetInventory().GetEquippedItem());
if (!DroppedItem.IsEmpty())
{
- if (GetInventory().RemoveOneEquippedItem())
+ char NewAmount = a_Amount;
+ if (NewAmount > GetInventory().GetEquippedItem().m_ItemCount)
{
- DroppedItem.m_ItemCount = 1; // RemoveItem decreases the count, so set it to 1 again
- Drops.push_back(DroppedItem);
+ NewAmount = GetInventory().GetEquippedItem().m_ItemCount; // Drop only what's there
}
+
+ GetInventory().GetHotbarGrid().ChangeSlotCount(GetInventory().GetEquippedSlotNum() /* Returns hotbar subslot, which HotbarGrid takes */, -a_Amount);
+
+ DroppedItem.m_ItemCount = NewAmount;
+ Drops.push_back(DroppedItem);
}
}
}