GenericRecipesManager

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

script.zs
import crafttweaker.api.GenericRecipesManager;

Description

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

Members

addJsonRecipe(name as string, data as MapData)
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.

script.zs
// GenericRecipesManager.addJsonRecipe(name as string, data as MapData);
myGenericRecipesManager.addJsonRecipe("recipe_name", {
type: "minecraft:smoking",
ingredient: <item:minecraft:gold_ore>,
result: <item:minecraft:cooked_porkchop>,
experience: 0.35 as float,
cookingtime: 100
});

Parameters:

name Type: string - The recipe's resource path
data Type: MapData - The recipe in JSON format
Getter
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.
script.zs
// GenericRecipesManager.allManagers as List<IRecipeManager<?>>
myGenericRecipesManager.allManagers

Return Type: List<IRecipeManager<?>>

allManagers() as List<IRecipeManager<?>>
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.
script.zs
// GenericRecipesManager.allManagers() as List<IRecipeManager<?>>;
myGenericRecipesManager.allManagers();

Return Type: List<IRecipeManager<?>>

Getter
script.zs
// GenericRecipesManager.allRecipes as List<RecipeHolder<Recipe<Container>>>
myGenericRecipesManager.allRecipes

Return Type: List<RecipeHolderRecipeHolder<Recipe<Container>>>

allRecipes() as List<RecipeHolder<Recipe<Container>>>
script.zs
// GenericRecipesManager.allRecipes() as List<RecipeHolder<Recipe<Container>>>;
myGenericRecipesManager.allRecipes();

Return Type: List<RecipeHolderRecipeHolder<Recipe<Container>>>

getRecipeByName(name as string) as RecipeHolder<Recipe<Container>>
script.zs
// GenericRecipesManager.getRecipeByName(name as string) as RecipeHolder<Recipe<Container>>;
myGenericRecipesManager.getRecipeByName(myString);

Parameters:

name Type: string

Return Type: RecipeHolderRecipeHolder<Recipe<Container>>

getRecipesByOutput(output as IIngredient) as List<RecipeHolder<Recipe<Container>>>
script.zs
// GenericRecipesManager.getRecipesByOutput(output as IIngredient) as List<RecipeHolder<Recipe<Container>>>;
myGenericRecipesManager.getRecipesByOutput(myIIngredient);

Parameters:

output Type: IIngredient

Return Type: List<RecipeHolderRecipeHolder<Recipe<Container>>>

getRecipesMatching(predicate as function(t as RecipeHolder<Recipe<Container>>) as bool) as List<RecipeHolder<Recipe<Container>>>
script.zs
// GenericRecipesManager.getRecipesMatching(predicate as function(t as RecipeHolder<Recipe<Container>>) as bool) as List<RecipeHolder<Recipe<Container>>>;
myGenericRecipesManager.getRecipesMatching(myPredicate);

Parameters:

predicate Type: function(t as RecipeHolderRecipeHolder<Recipe<Container>>) as bool

Return Type: List<RecipeHolderRecipeHolder<Recipe<Container>>>

Getter
Returns a map of all known recipes.
script.zs
// GenericRecipesManager.recipeMap as RecipeHolder<Recipe<Container>>[ResourceLocation]
myGenericRecipesManager.recipeMap

Return Type: RecipeHolderRecipeHolder<Recipe<Container>>[ResourceLocation]

recipeMap() as RecipeHolder<Recipe<Container>>[ResourceLocation]
Returns a map of all known recipes.

Returns: A Map of recipe name to recipe of all known recipes.

script.zs
// GenericRecipesManager.recipeMap() as RecipeHolder<Recipe<Container>>[ResourceLocation];
myGenericRecipesManager.recipeMap();

Return Type: RecipeHolderRecipeHolder<Recipe<Container>>[ResourceLocation]

remove(output as IIngredient)
Removes recipes by output
script.zs
// GenericRecipesManager.remove(output as IIngredient);
myGenericRecipesManager.remove(<item:minecraft:iron_ingot>);

Parameters:

output Type: IIngredient - The recipe result
removeAll()
Removes all recipes from all managers.
script.zs
// GenericRecipesManager.removeAll();
myGenericRecipesManager.removeAll();
removeByInput(input as IItemStack)
Removes all recipes where the input contains the given IItemStack.
script.zs
// GenericRecipesManager.removeByInput(input as IItemStack);
myGenericRecipesManager.removeByInput(<item:minecraft:iron_ingot>);

Parameters:

input Type: IItemStack - The input IItemStack.
removeByModid(modId as string)
Removes all recipes from the provided mod. Chooses the recipes based on their full recipe name, not based on output item!
script.zs
// GenericRecipesManager.removeByModid(modId as string);
myGenericRecipesManager.removeByModid("crafttweaker");

Parameters:

modId Type: string - The mod's modId
removeByModid(modId as string, exclude as function(t as string) as bool)
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!
script.zs
// GenericRecipesManager.removeByModid(modId as string, exclude as function(t as string) as bool);
myGenericRecipesManager.removeByModid("minecraft", (recipeName as string) => recipeName == "white_bed");

Parameters:

modId Type: string - The mod's modid
exclude Type: function(t as string) as bool - Function that returns true if the recipe should remain in the registry.
removeByName(names as string[])
Remove recipes based on Registry names
script.zs
// GenericRecipesManager.removeByName(names as string[]);
myGenericRecipesManager.removeByName(myString[]);

Parameters:

names Type: string[] - registry names of recipes to remove
removeByRegex(regex as string)
Remove recipe based on regex
script.zs
// GenericRecipesManager.removeByRegex(regex as string);
myGenericRecipesManager.removeByRegex("\\d_\\d");

Parameters:

regex Type: string - regex to match against
removeMatching(predicate as function(t as RecipeHolder<Recipe<Container>>) as bool)
Removes all recipes that match the given predicate
script.zs
// GenericRecipesManager.removeMatching(predicate as function(t as RecipeHolder<Recipe<Container>>) as bool);
myGenericRecipesManager.removeMatching((holder) => "wool" in holder.id.path);

Parameters:

predicate Type: function(t as RecipeHolderRecipeHolder<Recipe<Container>>) as bool - a predicate of RecipeHolder<Recipe<Container>> to test recipes against.