Yeah I normally just loop through the entire inventory, cast the default return object found to the item I’m looking for, then apply logic. You could loop through, create an array of ints for the inventory array indexes to directly reference the items in the inventory in a smaller loop rather than doing two full loops (cpu optimization).
And I know right? It took me a few weeks to figure out the correct way to manipulate item stack sizes (quantities*, used to mod Minecraft) because setting the itemQuantity to 0 doesn’t remove it, just now it’s weightless (altho dropping it and picking it up results in nothing, better to use the function that Wildcard created as it handles the removal of the item)