aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World
diff options
context:
space:
mode:
authorKevin <115616336+lag@users.noreply.github.com>2026-03-05 21:20:40 -0600
committerGitHub <noreply@github.com>2026-03-05 21:20:40 -0600
commitd22ab815e3006835ec55ffe75184be9d926b2547 (patch)
tree0ffb6c50cd8d974ed44ea1f69e4c31c34e120068 /Minecraft.World
parent0c2e27cae7b613644eca3a9b4e4778afe2094efb (diff)
Initial fixes for ContainerSetSlotPacket and CraftItemPacket (#649)
Diffstat (limited to 'Minecraft.World')
-rw-r--r--Minecraft.World/Inventory.cpp12
-rw-r--r--Minecraft.World/Inventory.h1
2 files changed, 13 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];
diff --git a/Minecraft.World/Inventory.h b/Minecraft.World/Inventory.h
index db5f42d6..539b9f49 100644
--- a/Minecraft.World/Inventory.h
+++ b/Minecraft.World/Inventory.h
@@ -68,6 +68,7 @@ public:
shared_ptr<ItemInstance> getResourceItem(int type,int iAuxVal);
bool hasResource(int type);
+ int countResource(int type, int auxVal);
void swapSlots(int from, int to);
bool add(shared_ptr<ItemInstance> item);
shared_ptr<ItemInstance> removeItem(unsigned int slot, int count);