public static void LoadRecipes() { foreach (string fullDirPath in Directory.GetDirectories(BlocksDirectory)) { string packageName = Path.GetFileName(fullDirPath); if (packageName.Equals("examples")) { continue; } Pipliz.Log.Write(string.Format("Started loading '{0}' recipes...", packageName)); try { foreach (string[] jobAndFilename in new string[][] { new string[] { "workbench", "crafting.json" }, new string[] { "tailorshop", "tailoring.json" }, new string[] { "grindstone", "grinding.json" }, new string[] { "mint", "minting.json" }, new string[] { "shop", "shopping.json" }, new string[] { "technologisttable", "technologist.json" }, new string[] { "furnace", "smelting.json" }, new string[] { "oven", "baking.json" } }) { JSONNode jsonRecipes; if (Pipliz.JSON.JSON.Deserialize(MultiPath.Combine(BlocksDirectory, packageName, jobAndFilename [1]), out jsonRecipes, false)) { if (jsonRecipes.NodeType == NodeType.Array) { foreach (JSONNode craftingEntry in jsonRecipes.LoopArray()) { foreach (string recipePart in new string[] { "results", "requires" }) { JSONNode jsonRecipeParts = craftingEntry.GetAs <JSONNode> (recipePart); foreach (JSONNode jsonRecipePart in jsonRecipeParts.LoopArray()) { string type = jsonRecipePart.GetAs <string> ("type"); string realtype; if (type.StartsWith(VANILLA_PREFIX)) { realtype = type.Substring(VANILLA_PREFIX.Length); } else { realtype = MOD_PREFIX + packageName + "." + type; } Pipliz.Log.Write(string.Format("Rewriting block recipe type from '{0}' to '{1}'", type, realtype)); jsonRecipePart.SetAs("type", realtype); } } Recipe craftingRecipe = new Recipe(craftingEntry); RecipeStorage.AddRecipe(craftingRecipe); RecipeStorage.AddBlockToRecipeMapping(jobAndFilename [0], craftingRecipe.Name); if (jobAndFilename [1].Equals("crafting.json")) { RecipePlayer.AddDefaultRecipe(craftingRecipe); } } } else { Pipliz.Log.WriteError(string.Format("Expected json array in {0}, but got {1} instead", jobAndFilename [1], jsonRecipes.NodeType)); } } } } catch (Exception exception) { Pipliz.Log.WriteError(string.Format("Exception while loading recipes from {0}; {1}", packageName, exception.Message)); } } }