use of mods.railcraft.common.util.inventory.iterators.IInvSlot in project Railcraft by Railcraft.
the class InventoryManipulator method tryRemoveItem.
/**
* Returns the item that would be returned if an item matching the filter
* was removed. Does not modify the inventory.
*/
@Nullable
public ItemStack tryRemoveItem(Predicate<ItemStack> filter) {
for (IInvSlot slot : this) {
ItemStack stack = slot.getStack();
if (!isEmpty(stack) && slot.canTakeStackFromSlot(stack) && filter.test(stack)) {
ItemStack output = stack.copy();
output.stackSize = 1;
return output;
}
}
return emptyStack();
}
Aggregations