CraftingTableRecipeManager

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.recipe.CraftingTableRecipeManager;

Description

Implements

CraftingTableRecipeManager implements the following interfaces:

IRecipeManager<CraftingRecipe>,CommandStringDisplayable

Undocumented Interfaces

Comparable<Enum>,Iterable<Recipe>

Enum Constants

CraftingTableRecipeManager is an enum with 1 constant. It is accessible like so:

script.zs
CraftingTableRecipeManager.INSTANCE

Members

addJsonRecipe(name as string, mapData as MapData)
Adds a recipe based on a provided IData. The provided IData should represent a DataPack json, this effectively allows you to register recipes for any DataPack supporting RecipeType systems.
script.zs
// CraftingTableRecipeManager.addJsonRecipe(name as string, mapData as MapData);
craftingTable.addJsonRecipe("recipe_name", {
ingredient: <item:minecraft:gold_ore>,
result: <item:minecraft:cooked_porkchop>.registryName,
experience: 0.35 as float,
cookingtime:100
});

Parameters:

name Type: string - name of the recipe
mapData Type: MapData - data representing the json file
addShaped(recipeName as string, output as IItemStack, ingredients as IIngredient[][], recipeFunction as RecipeFunction2D = null)
script.zs
// CraftingTableRecipeManager.addShaped(recipeName as string, output as IItemStack, ingredients as IIngredient[][], recipeFunction as RecipeFunction2D = null);
craftingTable.addShaped(myString, myIItemStack, myIIngredient[][], myRecipeFunction2D);

Parameters:

recipeName Type: string
output Type: IItemStack
ingredients Type: IIngredient[][]
recipeFunction (optional) Type: RecipeFunction2D

Default Value: null

addShapedMirrored(recipeName as string, mirrorAxis as MirrorAxis, output as IItemStack, ingredients as IIngredient[][], recipeFunction as RecipeFunction2D = null)
Adds a mirrored shaped recipe to the crafting table.
This method lets you provide a MirrorAxis, which can be used to set which axis the recipe is mirrored on. Use cases are making a recipe only be mirrored vertically or only horizontally.
script.zs
// CraftingTableRecipeManager.addShapedMirrored(recipeName as string, mirrorAxis as MirrorAxis, output as IItemStack, ingredients as IIngredient[][], recipeFunction as RecipeFunction2D = null);
craftingTable.addShapedMirrored("recipe_name", MirrorAxis.DIAGONAL, <item:minecraft:dirt>, [[<item:minecraft:diamond>], [<tag:items:minecraft:wool>]], (usualOut as IItemStack, inputs as IItemStack[][]) => {if(inputs[0][0].displayName == "totally real diamond block" ){return usualOut;}return <item:minecraft:clay>.setDisplayName("Diamond");});

Parameters:

recipeName Type: string - name of the recipe to add.
mirrorAxis Type: MirrorAxis - The axis that this recipe mirrored on.
output Type: IItemStack - output IItemStack
ingredients Type: IIngredient[][] - array of an array of IIngredient for inputs
recipeFunction (optional) Type: RecipeFunction2D - optional RecipeFunction2D for more advanced conditions

Default Value: null

addShapedPattern(recipeName as string, output as IItemStack, pattern as string[], keys as IIngredient[string], recipeFunction as RecipeFunction2D = null)
script.zs
// CraftingTableRecipeManager.addShapedPattern(recipeName as string, output as IItemStack, pattern as string[], keys as IIngredient[string], recipeFunction as RecipeFunction2D = null);
craftingTable.addShapedPattern(myString, myIItemStack, myString[], myMap, myRecipeFunction2D);

Parameters:

recipeName Type: string
output Type: IItemStack
pattern Type: string[]
keys Type: IIngredient[string]
recipeFunction (optional) Type: RecipeFunction2D

Default Value: null

addShapeless(recipeName as string, output as IItemStack, ingredients as IIngredient[], recipeFunction as RecipeFunction1D = null)
script.zs
// CraftingTableRecipeManager.addShapeless(recipeName as string, output as IItemStack, ingredients as IIngredient[], recipeFunction as RecipeFunction1D = null);
craftingTable.addShapeless(myString, myIItemStack, myIIngredient[], myRecipeFunction1D);

Parameters:

recipeName Type: string
output Type: IItemStack
ingredients Type: IIngredient[]
recipeFunction (optional) Type: RecipeFunction1D

Default Value: null

Getter
script.zs
// CraftingTableRecipeManager.allRecipes as List<Recipe>
craftingTable.allRecipes

Return Type: List<Recipe>

allRecipes() as List<Recipe>
script.zs
// CraftingTableRecipeManager.allRecipes() as List<Recipe>;
craftingTable.allRecipes();

Return Type: List<Recipe>

Getter
Returns the BEP to get this thingy
script.zs
// CraftingTableRecipeManager.commandString as string
craftingTable.commandString

Return Type: string

commandString() as string
Returns the BEP to get this thingy
script.zs
// CraftingTableRecipeManager.commandString() as string;
craftingTable.commandString();

Return Type: string

getRecipeByName(name as string) as Recipe?
script.zs
// CraftingTableRecipeManager.getRecipeByName(name as string) as Recipe?;
craftingTable.getRecipeByName(myString);

Parameters:

name Type: string

Return Type: Recipe?

getRecipesByOutput(output as IIngredient) as List<Recipe>
script.zs
// CraftingTableRecipeManager.getRecipesByOutput(output as IIngredient) as List<Recipe>;
craftingTable.getRecipesByOutput(myIIngredient);

Parameters:

output Type: IIngredient

Return Type: List<Recipe>

Getter
Returns a map of all known recipes.
script.zs
// CraftingTableRecipeManager.recipeMap as Recipe[ResourceLocation]
craftingTable.recipeMap

Return Type: Recipe[ResourceLocation]

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

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

script.zs
// CraftingTableRecipeManager.recipeMap() as Recipe[ResourceLocation];
craftingTable.recipeMap();

Return Type: Recipe[ResourceLocation]

remove(output as IIngredient)
Remove a recipe based on it's output.
script.zs
// CraftingTableRecipeManager.remove(output as IIngredient);
craftingTable.remove(<tag:items:minecraft:wool>);

Parameters:

output Type: IIngredient - output of the recipe
removeAll()
Remove all recipes in this registry
script.zs
// CraftingTableRecipeManager.removeAll();
craftingTable.removeAll();
removeByInput(input as IItemStack)
Removes all recipes where the input contains the given IItemStack.
script.zs
// CraftingTableRecipeManager.removeByInput(input as IItemStack);
craftingTable.removeByInput(<item:minecraft:iron_ingot>);

Parameters:

input Type: IItemStack - The input IItemStack.
removeByModid(modid as string, exclude as function(t as string) as bool = (name as string) as bool => false)
Remove recipe based on Registry name modid
script.zs
// CraftingTableRecipeManager.removeByModid(modid as string, exclude as function(t as string) as bool = (name as string) as bool => false);
craftingTable.removeByModid("minecraft", myPredicate);

Parameters:

modid Type: string - modid of the recipes to remove
exclude (optional) Type: function(t as string) as bool

Default Value: (name as string) as bool => false

removeByName(names as string[])
Remove recipes based on Registry names
script.zs
// CraftingTableRecipeManager.removeByName(names as string[]);
craftingTable.removeByName(myString[]);

Parameters:

names Type: string[] - registry names of recipes to remove
removeByRegex(regex as string, exclude as function(t as string) as bool = (name as string) as bool => false)
Remove recipe based on regex with an added exclusion check, so you can remove the whole mod besides a few specified.
script.zs
// CraftingTableRecipeManager.removeByRegex(regex as string, exclude as function(t as string) as bool = (name as string) as bool => false);
craftingTable.removeByRegex("\\d_\\d", (name as string) => {return name == "orange_wool";});

Parameters:

regex Type: string - regex to match against
exclude (optional) Type: function(t as string) as bool

Default Value: (name as string) as bool => false