Recipe Managers
Link to recipe-managers
Recipe Managers are crafting systems (like the Crafting Table, Furnace or Camp Fire) that use the Vanilla Data Pack JSON system.
Most Recipe Managers have the same removal methods but different methods to add recipes.
Recipe Managers are generally what you will be using to interact with recipes in the game, there are however some mods that don't use the DataPack JSON system, and for those mods you would need to add and remove recipes differently.
Referencing Recipe Managers
Link to referencing-recipe-managers
Recipe Managers are usually referenced via a Bracket Handler (the exception being Vanilla Recipe Managers which can be referenced via a global value).
The Recipe manager format is:
ZenScript Copy<recipetype:modid:name>
Some examples are:
ZenScript Copy<recipetype:minecraft:smoking> // References the Smoking Recipe Manager
<recipetype:botania:mana_infusion> // References the Botania Mana Infusion Recipe Manager
<recipetype:thermal:pulverizer> // References the Thermal Expansion Pulverizer Recipe Manager
Vanilla Recipe Managers are special as they have dedicated Global Variables that allow you to reference them without using a BracketHandler.
The Vanilla Recipe Managers are:
Recipe Manager | Bracket Handler | Global Variable |
---|---|---|
Recipe Manager Blasting | Bracket Handler <recipetype:minecraft:blasting> | Global Variable blastFurnace |
Recipe Manager Campfire Cooking | Bracket Handler <recipetype:minecraft:campfire_cooking> | Global Variable campfire |
Recipe Manager Crafting | Bracket Handler <recipetype:minecraft:crafting> | Global Variable craftingTable |
Recipe Manager Smelting | Bracket Handler <recipetype:minecraft:smelting> | Global Variable furnace |
Recipe Manager Smithing | Bracket Handler <recipetype:minecraft:smithing> | Global Variable smithing |
Recipe Manager Smoking | Bracket Handler <recipetype:minecraft:smoking> | Global Variable smoker |
Recipe Manager Stone Cutting | Bracket Handler <recipetype:minecraft:stonecutting> | Global Variable stoneCutter |
The Vanilla Recipe Managers can be referenced by either their Bracket Handler or the Global Variable, for example:
ZenScript Copy<recipetype:minecraft:blasting>.removeAll() // Removes all Blast Furnace Recipes
Is the same as doing:
ZenScript CopyblastFurnace.removeAll() // Removes all Blast Furnace Recipes
The Global Variables just allow the Recipe Managers to be referenced easier.
The reason that not all Recipe Managers are given Global Variables is that there would be conflicting names if two different mods both added a machine with the same name, such as two mods adding Crushers.
Methoden
Link to methoden
Name: getRecipeByName
This method gets a recipe by it's name, and returns a WrapperRecipe.
ZenScript CopygetRecipeByName(String name);
You could use this method to get the ingredients
of a recipe and print the commandString
of each ingredient.
ZenScript Copyfor ingredient in craftingTable.getRecipeByName("minecraft:arrow").ingredients {
println(ingredient.commandString);
}
Name: getRecipesByOutput
This method gets a list of recipes based on their outputs, and returns a list of WrapperRecipe.
ZenScript CopygetRecipesByOutput(IIngredient name);
You could use this method to get the ingredients
of all the recipes that output a certain item and print the commandString
of each ingredient of each recipe.
ZenScript Copyfor recipe in craftingTable.getRecipesByOutput(<item:minecraft:stick>) {
println("> " + recipe.id);
for ingredient in recipe.ingredients {
println(ingredient.commandString);
}
}
Name: getAllRecipes
This method gets a list of all the recipes for the Recipe Manager and returns a list of WrapperRecipe.
ZenScript CopygetAllRecipes();
You could use this method to get the ingredients
of all the recipes and print the commandString
of each ingredient of each recipe.
ZenScript Copyfor recipe in furnace.getAllRecipes() {
println("> " + recipe.id);
for ingredient in recipe.ingredients {
println(ingredient.commandString);
}
}
Name: remove
This method allows you to remove recipes from this Recipe Manager by the recipe's output item.
ZenScript Copyremove(IItemStack output);
An example use case for this method is removing the recipe for Sticks from the Crafting Table:
ZenScript CopycraftingTable.remove(<item:minecraft:stick>);
Another example of this method would be removing the Diamond Ore to Diamond recipe from the furnace:
ZenScript Copyfurnace.remove(<item:minecraft:diamond>);
Name: removeByName
This method allows you to remove recipes from this Recipe Manager by the recipe's name.
ZenScript CopyremoveByName(String name);
An example use case for this method is removing the recipe for an Arrow from the Crafting Table:
ZenScript CopycraftingTable.removeByName("minecraft:arrow");
Name: removeByModid
This method allows you to remove recipes from this Recipe Manager based on the the recipe name's modid.
There is an optional parameter that is used to exclude recipes from being removed.
Note: The name given to the RecipeFilter is just the path of the recipe id.
For example, if the recipe id is minecraft:orange_wool
, the name given will be orange_wool
. Another example would be the recipe id modid:path/name
, the name given will be path/name
ZenScript CopyremoveByModid(String modid);
or
removeByModid(String modid, RecipeFilter exclude);
An example use case for this method is removing all the recipe from "minecraft" from the Crafting Table:
ZenScript CopycraftingTable.removeByModid("minecraft");
Another use case would be removing all the recipes from "minecraft" excluding the recipe for Orange Wool.
ZenScript CopycraftingTable.removeByModid("minecraft", (name as string) => {
return name == "orange_wool";
});
Name: removeByRegex
This method allows you to remove recipes from this Recipe Manager by testing the recipe's id against a regex pattern.
ZenScript CopyremoveByRegex(String regex);
An example use case for this method is removing all recipes who's id matches .*wool.*
(anything that has the work wool
in it).
ZenScript CopycraftingTable.removeByRegex(".*wool.*");
Name: removeAll
This method allows you to remove all the recipes from the Recipe Manager.
ZenScript CopyremoveAll(String regex);
An example use case for this method is removing all the Blast Furnace recipes.
ZenScript CopyblastFurnace.removeAll();