public void Register(CraftingRecipe recipe) { if (!Recipes.Contains(recipe)) { Recipes.Add(recipe); } }
/// <summary> /// Internal CraftRecipe. /// Performs the actual crafting of the recipe. /// </summary> /// <param name="recipe">CraftingRecipe</param> /// <param name="container">Input container</param> /// <param name="simulate">If true; does not subtract the ingredients from the container</param> /// <returns></returns> private ItemStack[] PerformCraftRecipe(CraftingRecipe recipe, Container container = null, bool simulate = false) { if (!simulate) { container.Remove(ItemStack.CloneMultiple(true, recipe.RecipeIngredients)); } return ItemStack.GetPersistantMultiple(recipe.Output); }
/// <summary> /// Craft a specific CraftingRecipe. /// Will check if the CraftingRecipe is allowed on this Crafter. /// </summary> /// <param name="recipe">CraftingRecipe</param> /// <param name="container">Force input container; if null, uses input</param> /// <param name="simulate">If true; does not subtract the ingredients from the container</param> /// <returns></returns> public ItemStack[] CraftRecipe(CraftingRecipe recipe, Container container = null, bool simulate = false) { if (container == null) { container = input; } var recipes = GetRecipes(); if (!recipes.Contains(recipe)) { return null; } return PerformCraftRecipe(recipe, container, simulate); }