summaryrefslogtreecommitdiffstats
path: root/src/Inventory.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-20 13:02:23 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-20 13:02:23 +0200
commitd0e7b2f18b15afbc78adfdcf7d1b7b3511a0a6ab (patch)
tree4f283dd99354a72bb8ba30da637b38adb5521b76 /src/Inventory.cpp
parentProper comment for DropBlock() (diff)
parentNBTChunkSerializer.cpp: Added break after serializing the splash potion (diff)
downloadcuberite-d0e7b2f18b15afbc78adfdcf7d1b7b3511a0a6ab.tar
cuberite-d0e7b2f18b15afbc78adfdcf7d1b7b3511a0a6ab.tar.gz
cuberite-d0e7b2f18b15afbc78adfdcf7d1b7b3511a0a6ab.tar.bz2
cuberite-d0e7b2f18b15afbc78adfdcf7d1b7b3511a0a6ab.tar.lz
cuberite-d0e7b2f18b15afbc78adfdcf7d1b7b3511a0a6ab.tar.xz
cuberite-d0e7b2f18b15afbc78adfdcf7d1b7b3511a0a6ab.tar.zst
cuberite-d0e7b2f18b15afbc78adfdcf7d1b7b3511a0a6ab.zip
Diffstat (limited to 'src/Inventory.cpp')
-rw-r--r--src/Inventory.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/Inventory.cpp b/src/Inventory.cpp
index bce882c88..5f7c24b60 100644
--- a/src/Inventory.cpp
+++ b/src/Inventory.cpp
@@ -151,6 +151,24 @@ int cInventory::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, bool a
+int cInventory::RemoveItem(const cItem & a_ItemStack)
+{
+ int RemovedItems = m_HotbarSlots.RemoveItem(a_ItemStack);
+
+ if (RemovedItems < a_ItemStack.m_ItemCount)
+ {
+ cItem Temp(a_ItemStack);
+ Temp.m_ItemCount -= RemovedItems;
+ RemovedItems += m_InventorySlots.RemoveItem(Temp);
+ }
+
+ return RemovedItems;
+}
+
+
+
+
+
bool cInventory::RemoveOneEquippedItem(void)
{
if (m_HotbarSlots.GetSlot(m_EquippedSlotNum).IsEmpty())
@@ -493,7 +511,7 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size,
if( NumFree >= a_Item.m_ItemCount )
{
- //printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree );
+ // printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree );
m_Slots[i + a_Offset].m_ItemCount += a_Item.m_ItemCount;
a_Item.m_ItemCount = 0;
a_bChangedSlots[i + a_Offset] = true;
@@ -501,7 +519,7 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size,
}
else
{
- //printf("2. Adding %i items\n", NumFree );
+ // printf("2. Adding %i items\n", NumFree );
m_Slots[i + a_Offset].m_ItemCount += (char)NumFree;
a_Item.m_ItemCount -= (char)NumFree;
a_bChangedSlots[i + a_Offset] = true;