public bool TryTakeNOfType(ItemType itemType, int n, out ItemStack stack) { stack = null; foreach (var slot in Slots) { stack = ItemStack.Combine(stack, slot.TakeNOfType(itemType, n)); if (stack != null && stack.Size == n) { break; } } return(stack != null); }