diff --git a/src/main/java/net/wurstclient/util/InventoryUtils.java b/src/main/java/net/wurstclient/util/InventoryUtils.java index a067f0a371..eaf18cfa9e 100644 --- a/src/main/java/net/wurstclient/util/InventoryUtils.java +++ b/src/main/java/net/wurstclient/util/InventoryUtils.java @@ -101,6 +101,9 @@ public static int count(Predicate predicate, int maxInvSlot) * Counts the number of items in the player's inventory that match the given * predicate, searching from slot 0 to {@code maxInvSlot-1}. * + *

+ * Note: Attempting to count empty slots will always return 0. + * * @param predicate * checks if an item should be counted * @param maxInvSlot @@ -114,8 +117,10 @@ public static int count(Predicate predicate, int maxInvSlot) public static int count(Predicate predicate, int maxInvSlot, boolean includeOffhand) { - return (int)getMatchingSlots(predicate, maxInvSlot, includeOffhand) - .count(); + PlayerInventory inventory = MC.player.getInventory(); + + return getMatchingSlots(predicate, maxInvSlot, includeOffhand) + .map(slot -> inventory.getStack(slot).getCount()).sum(); } private static IntStream getMatchingSlots(Predicate predicate,