Remove all matching items up to a maximum, returning the number that were removed @param inv The inventory to count and remove items from @param item The item to count and remove @param max The maximum number of items to remove @param comparison A filter to compare items for cou
(Inventory inv, ItemStack item, int max, BiPredicate<ItemStack, ItemStack> comparison)
| 452 | * @return How many items were removed |
| 453 | */ |
| 454 | public static int countAndRemove(Inventory inv, ItemStack item, int max, BiPredicate<ItemStack, ItemStack> comparison) { |
| 455 | int count = count(inv, item, comparison); |
| 456 | count = Math.min(max, count); |
| 457 | remove(inv, item, count, comparison); |
| 458 | return count; |
| 459 | } |
| 460 | |
| 461 | /** |
| 462 | * Remove all matching items up to a maximum, returning the number that were removed |