SmithingRecipeManager

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

Implemented Interfaces

SmithingRecipeManager implements the following interfaces. That means all methods defined in these interfaces are also available in SmithingRecipeManager

Enum Constants

SmithingRecipeManager is an enum. It has 1 enum constants. They are accessible using the code below.

script.zs
SmithingRecipeManager.INSTANCE

Methods

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
// SmithingRecipeManager.addJsonRecipe(name as string, mapData as MapData)
smithing.addJsonRecipe("recipe_name", {
ingredient: <item:minecraft:gold_ore>,
result: <item:minecraft:cooked_porkchop>.registryName,
experience: 0.35 as float,
cookingtime:100
});
ParameterTypeDescription
Parameter
name
Type
string
Description
name of the recipe
Parameter
mapData
Type
MapData
Description
data representing the json file

Adds a new transform recipe to the smithing table.

script.zs
SmithingRecipeManager.addTransformRecipe(recipeName as string, result as IItemStack, template as IIngredient, base as IIngredient, addition as IIngredient)
ParameterTypeDescription
Parameter
recipeName
Type
string
Description
Name of the recipe.
Parameter
result
Type
IItemStack
Description
The item created by the recipe.
Parameter
template
Type
IIngredient
Description
The template to use.
Parameter
base
Type
IIngredient
Description
The initial ingredient for the recipe.
Parameter
addition
Type
IIngredient
Description
The item added to the base item.

Adds a new trim recipe to the smithing table.

script.zs
SmithingRecipeManager.addTrimRecipe(recipeName as string, template as IIngredient, base as IIngredient, addition as IIngredient)
ParameterTypeDescription
Parameter
recipeName
Type
string
Description
Name of the recipe.
Parameter
template
Type
IIngredient
Description
The template to use.
Parameter
base
Type
IIngredient
Description
The initial ingredient for the recipe.
Parameter
addition
Type
IIngredient
Description
The item added to the base item.

Return Type: stdlib.List<T>

script.zs
// SmithingRecipeManager.getAllRecipes() as stdlib.List<T>
smithing.getAllRecipes();

Return Type: @org.openzen.zencode.java.ZenCodeType.Nullable T

script.zs
SmithingRecipeManager.getRecipeByName(name as string) as @org.openzen.zencode.java.ZenCodeType.Nullable T
ParameterType
Parameter
name
Type
string

Returns a map of all known recipes.

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

script.zs
// SmithingRecipeManager.getRecipeMap() as T[ResourceLocation]
smithing.getRecipeMap();

Return Type: stdlib.List<T>

script.zs
SmithingRecipeManager.getRecipesByOutput(output as IIngredient) as stdlib.List<T>
ParameterType
Parameter
output
Type
IIngredient

Remove a recipe based on it’s output.

script.zs
// SmithingRecipeManager.remove(output as IIngredient)
smithing.remove(<tag:items:minecraft:wool>);
ParameterTypeDescription
Parameter
output
Type
IIngredient
Description
output of the recipe

Remove all recipes in this registry

script.zs
// SmithingRecipeManager.removeAll()
smithing.removeAll();

Removes all recipes where the input contains the given IItemStack.

script.zs
// SmithingRecipeManager.removeByInput(input as IItemStack)
smithing.removeByInput(<item:minecraft:iron_ingot>);
ParameterTypeDescription
Parameter
input
Type
IItemStack
Description
The input IItemStack.

Remove recipe based on Registry name modid

script.zs
SmithingRecipeManager.removeByModid(modid as string, exclude as Predicate<string>)
ParameterTypeDescriptionOptionalDefault Value
Parameter
modid
Type
string
Description
modid of the recipes to remove
Optional
false
Default Value
Parameter
exclude
Type
Predicate<string>
Description
Optional
true
Default Value
(name as string) as bool => false

Remove recipes based on Registry names

script.zs
SmithingRecipeManager.removeByName(names as string[])
ParameterTypeDescription
Parameter
names
Type
string[]
Description
registry names of recipes to remove

Remove recipe based on regex with an added exclusion check, so you can remove the whole mod besides a few specified.

script.zs
// SmithingRecipeManager.removeByRegex(regex as string, exclude as Predicate<string>)
smithing.removeByRegex("\\d_\\d", (name as string) => {return name == "orange_wool";});
ParameterTypeDescriptionOptionalDefault Value
Parameter
regex
Type
string
Description
regex to match against
Optional
false
Default Value
Parameter
exclude
Type
Predicate<string>
Description
Optional
true
Default Value
(name as string) as bool => false

Properties

NameTypeHas GetterHas SetterDescription
Name
allRecipes
Type
stdlib.List<T>
Has Getter
true
Has Setter
false
Description
Name
recipeMap
Type
T[ResourceLocation]
Has Getter
true
Has Setter
false
Description
Returns a map of all known recipes.