public bool Matches(ItemStack[] inputStacks, ref int quantityServings) { List <ItemStack> inputStacksList = new List <ItemStack>(inputStacks); List <CookingRecipeIngredient> ingredientList = new List <CookingRecipeIngredient>(Ingredients); int totalOutputQuantity = 99999; int[] curQuantities = new int[ingredientList.Count]; for (int i = 0; i < curQuantities.Length; i++) { curQuantities[i] = 0; } while (inputStacksList.Count > 0) { ItemStack inputStack = inputStacksList[0]; inputStacksList.RemoveAt(0); if (inputStack == null) { continue; } bool found = false; for (int i = 0; i < ingredientList.Count; i++) { CookingRecipeIngredient ingred = ingredientList[i]; if (ingred.Matches(inputStack)) { if (curQuantities[i] >= ingred.MaxQuantity) { continue; } totalOutputQuantity = Math.Min(totalOutputQuantity, inputStack.StackSize); curQuantities[i]++; found = true; break; } } // This input stack does not fit in this cooking recipe if (!found) { return(false); } } // Any required ingredients left? for (int i = 0; i < ingredientList.Count; i++) { if (curQuantities[i] < ingredientList[i].MinQuantity) { return(false); } } quantityServings = totalOutputQuantity; // Too many ingredients? for (int i = 0; i < inputStacks.Length; i++) { var stack = inputStacks[i]; if (stack == null) { continue; } int qportions = stack.StackSize; if (stack.Collectible.Attributes?["waterTightContainerProps"].Exists == true) { var props = BlockLiquidContainerBase.GetContainableProps(stack); qportions = (int)(stack.StackSize / props.ItemsPerLitre / GetIngrendientFor(stack).PortionSizeLitres); } if (qportions != quantityServings) { return(false); } } return(true); }