Home Migration Guide Getting Started With Scripts Commands Examples
BracketHandlers

GenericRecipesManager

This recipe manager allows you to perform removal actions over all recipe managers. You can access this manager by using the recipes global keyword.

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

script.zs
import crafttweaker.api.GenericRecipesManager;

Methods

Add a new recipe based on the given recipe in a valid DataPack JSON format.

Unlike the addJSONRecipe method in IRecipeManager you must set the type of the recipe within the JSON yourself.

Return Type: void

script.zs
// GenericRecipesManager.addJSONRecipe(name as string, data as IData) as void
recipes.addJSONRecipe("recipe_name", {
type: "minecraft:smoking",
ingredient: <item:minecraft:gold_ore>,
result: <item:minecraft:cooked_porkchop>,
experience: 0.35 as float,
cookingtime: 100
});
ParameterTypeDescription
Parameter
name
Type
string
Description
The recipe’s resource path
Parameter
data
Type
IData
Description
The recipe in JSON format

Returns a list of all known recipe managers. This includes managers added by mod integrations as well as wrapper managers added to provide simple support.

Return Type: stdlib.List<IRecipeManager>

script.zs
// GenericRecipesManager.getAllManagers() as stdlib.List<IRecipeManager>
recipes.getAllManagers();

Return Type: stdlib.List<WrapperRecipe>

script.zs
// GenericRecipesManager.getAllRecipes() as stdlib.List<WrapperRecipe>
recipes.getAllRecipes();

Return Type: WrapperRecipe

script.zs
GenericRecipesManager.getRecipeByName(name as string) as WrapperRecipe
ParameterTypeDescription
Parameter
name
Type
string
Description
No Description Provided

Returns a map of all known recipes.

Returns: A Map of recipe name to recipe of all known recipes.
Return Type: WrapperRecipe[MCResourceLocation]

script.zs
// GenericRecipesManager.getRecipeMap() as WrapperRecipe[MCResourceLocation]
recipes.getRecipeMap();

Return Type: stdlib.List<WrapperRecipe>

script.zs
GenericRecipesManager.getRecipesByOutput(output as IIngredient) as stdlib.List<WrapperRecipe>
ParameterTypeDescription
Parameter
output
Type
IIngredient
Description
No Description Provided

Removes all recipes from all managers.

Return Type: void

script.zs
// GenericRecipesManager.removeAll() as void
recipes.removeAll();

Removes all recipes from the provided mod. Chooses the recipes based on their full recipe name, not based on output item!

Return Type: void

script.zs
// GenericRecipesManager.removeByModid(modId as string) as void
recipes.removeByModid("crafttweaker");
ParameterTypeDescription
Parameter
modId
Type
string
Description
The mod’s modId

Removes all recipes from the provided mod. Allows a function to exclude certain recipe names from being removed. In the example below, only the recipe for the white bed would remain. Since the recipe’s namespace is already fixed based on the modId argument, the recipe filter will only check the resource path!

Return Type: void

script.zs
// GenericRecipesManager.removeByModid(modId as string, exclude as RecipeFilter) as void
recipes.removeByModid("minecraft", (recipeName as string) => recipeName == "white_bed");
ParameterTypeDescription
Parameter
modId
Type
string
Description
The mod’s modid
Parameter
exclude
Type
RecipeFilter
Description
Function that returns true if the recipe should remain in the registry.

Removes all recipes with this name.

Return Type: void

script.zs
GenericRecipesManager.removeByName(name as string) as void
ParameterTypeDescription
Parameter
name
Type
string
Description
The recipe name to remove

Remove recipe based on regex

Return Type: void

script.zs
// GenericRecipesManager.removeByRegex(regex as string) as void
recipes.removeByRegex("\\d_\\d");
ParameterTypeDescription
Parameter
regex
Type
string
Description
regex to match against

Removes recipes by output

Return Type: void

script.zs
// GenericRecipesManager.removeRecipe(output as IIngredient) as void
recipes.removeRecipe(<item:minecraft:iron_ingot>);
ParameterTypeDescription
Parameter
output
Type
IIngredient
Description
The recipe result

Removes all recipes who’s input contains the given IItemStack.

Return Type: void

script.zs
// GenericRecipesManager.removeRecipeByInput(input as IItemStack) as void
recipes.removeRecipeByInput(<item:minecraft:iron_ingot>);
ParameterTypeDescription
Parameter
input
Type
IItemStack
Description
The input IItemStack.

Properties

NameTypeHas GetterHas SetterDescription
Name
allManagers
Type
stdlib.List<IRecipeManager>
Has Getter
true
Has Setter
false
Description
Returns a list of all known recipe managers.
This includes managers added by mod integrations as well as wrapper managers added to provide simple support.
Name
allRecipes
Type
stdlib.List<WrapperRecipe>
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
recipeMap
Type
WrapperRecipe[MCResourceLocation]
Has Getter
true
Has Setter
false
Description
Returns a map of all known recipes.