aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Inventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.World/Inventory.cpp')
-rw-r--r--Minecraft.World/Inventory.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/Minecraft.World/Inventory.cpp b/Minecraft.World/Inventory.cpp
index 1b9ff630..4a524bab 100644
--- a/Minecraft.World/Inventory.cpp
+++ b/Minecraft.World/Inventory.cpp
@@ -343,6 +343,18 @@ bool Inventory::hasResource(int type)
return true;
}
+int Inventory::countResource(int type, int auxVal)
+{
+ int count = 0;
+ for (unsigned int i = 0; i < items.length; i++)
+ {
+ if (items[i] != NULL && items[i]->id == type &&
+ (auxVal == -1 || items[i]->getAuxValue() == auxVal))
+ count += items[i]->count;
+ }
+ return count;
+}
+
void Inventory::swapSlots(int from, int to)
{
shared_ptr<ItemInstance> tmp = items[to];