There are three recipe types for crafting tables:
Shapeless: A shapeless recipe is a recipe where the position of the input items in the crafting grid does not matter.
Shaped: A shaped recipe is a recipe where the position of the items must be exact.
Shaped Mirrored: A mirrored recipe is like shaped recipes but mirrors the recipe along the horizontal or vertical axes.
When adding a recipe, ensure that your recipe names are unique!
craftingTable.addShapeless(recipeName, output, ingredients, recipeFunction);
Adds a shapeless recipe to the crafting table. As shapeless recipes ignore the position of the input items, the ordering of the items when creating the recipe does not matter either.
Shapeless recipes can have up to 9 inputs, but those with 4 or less inputs can also be crafted in the 2x2 inventory grid.
Crafting Table Recipes can also output more than 1 amount of the output item. This can be achieved by using the IItemStack multiplication operator on the output item.
craftingTable . addShapeless ( "shapeless_example_1" , < item : minecraft:grass > , [ < item : minecraft:wheat_seeds > , < item : minecraft:dirt > ] ) ;
// A shapeless recipe can have up to 9 inputs
// This also demonstrates that more than one output can be used. In this example, 8 grass will be outputted.
craftingTable . addShapeless( "shapeless_example_2" , < item : minecraft:grass > * 8 , [ < item : minecraft:wheat_seeds > , < item : minecraft:dirt > , < item : minecraft:dirt > , < item : minecraft:dirt > , < item : minecraft:dirt > , < item : minecraft:dirt > , < item : minecraft:dirt > , < item : minecraft:dirt > , < item : minecraft:dirt > ]);
See Using Recipe Functions for examples on how to use recipe functions.
craftingTable.addShaped(recipeName, output, ingredients, recipeFunction);
craftingTable.addShapedMirrored(recipeName, output, ingredients, recipeFunction);
Adds a shaped (or mirrored , depending on the function) recipe to the crafting table. The ordering of the items when creating the recipe dictates the position of each item in the crafting grid.
Making the recipe a shaped mirrored recipe instead allows for more flexibility to the player when adding the items to the crafting grid.
Both shaped and shaped mirrored recipes can be made to work in a 2x2 (inventory) or 3x3 crafting grid.
Crafting Table Recipes can also output more than 1 amount of the output item. This can be achieved by using the IItemStack multiplication operator on the output item.
// Adding a shaped recipe
craftingTable . addShaped( "shaped_example_1" , < item : minecraft:arrow > , [
[ < item : minecraft:diamond > , < item : minecraft:diamond > ],
[ < item : minecraft:air > , < item : minecraft:flint > ],
[ < item : minecraft:air > , < item : minecraft:flint > ]
// Adding a shaped 2x2 recipe (this can also be done as mirrored)
craftingTable . addShaped( "shaped_example_2" , < item : minecraft:diamond_axe > , [
[ < item : minecraft:diamond > , < item : minecraft:diamond > ],
[ < item : minecraft:diamond > , < item : minecraft:stick > ]
// Adding a shaped mirrored recipe
import crafttweaker . api.recipe . MirrorAxis;
craftingTable . addShapedMirrored( "shaped_mirror_example_1" , MirrorAxis . DIAGONAL, < item : minecraft:arrow > * 2 , [
[ < item : minecraft:diamond > , < item : minecraft:diamond > ],
[ < item : minecraft:air > , < item : minecraft:flint > ],
[ < item : minecraft:air > , < item : minecraft:flint > ]
See Using Recipe Functions for examples on how to use recipe functions.
A recipe function allows for a programatically determined output. This can be especially useful when you need some of the input item’s information, like the item’s damage or other NBT data.
As Shaped and Shaped Mirrored Recipes are similar, examples will only include Shaped Recipes. You may treat any example using addShaped
as the same as using addShapedMirrored
.
recipeFunction
<RecipeFunctionArray >
(usualOut as IItemStack, inputs as IItemStack[]) => {};
usualOut
as IItemStack
inputs
as IItemStack [] Array of inputs ordered the same as defined in the original recipe
import crafttweaker . api.item . IItemStack;
craftingTable . addShapeless ( "shapeless_func_example_1" , < item : minecraft:diamond > * 9 , [ < item : minecraft:dirt > , < item : minecraft:stick > ] , ( usualOut as IItemStack, inputs as IItemStack [ ] ) = > {
// Checks if <item:minecraft:dirt> has a display name of "totally real diamond block"
if (inputs[ 0 ].displayName == "totally real diamond block" ) {
// Returns <item:minecraft:diamond> * 9
// Otherwise, return <item:minecraft:clay> with a display name of "Diamond"
return < item : minecraft:clay > .setDisplayName( "Diamond" );
recipeFunction
<RecipeFunctionMatrix >
(usualOut as IItemStack, inputs as IItemStack[][]) => {};
inputs
is an array of inputs ordered the same as defined in the original recipe. An input can be found by defining the row, then the column (inputs[0][1]
to get the item in the first row, second column).
import crafttweaker . api.item . IItemStack;
craftingTable . addShaped ( "shapeed_func_example_1" , < item : minecraft:diamond_block > , [
[ < item : minecraft:clay_ball > , < item : minecraft:clay_ball > , < item : minecraft:clay_ball > ] ,
[ < item : minecraft:clay_ball > , < item : minecraft:diamond > , < item : minecraft:clay_ball > ] ,
[ < item : minecraft:clay_ball > , < item : minecraft:clay_ball > , < item : minecraft:clay_ball > ]
] , ( usualOut as IItemStack, inputs as IItemStack [ ] [ ] ) = > {
// Checks if all <item:minecraft:clay_ball> has a display name of "Diamond"
if ( < item : minecraft:clay_ball > .matches(recipeItem) && recipeItem . displayName == "Diamond" ) {
// If the recipe item is <item:minecraft:clay_ball> and has a name of "Diamond" increment the counter
// If we have 8 <item:minecraft:clay_ball> with a name of "Diamond"
if (inputs[ 1 ][ 1 ].displayName == "Special Diamond" ) {
// If <item:minecraft:diamond> has a display name of "Special Diamond"
// Return 2 <item:minecraft:diamond_block>
// Returns <item:minecraft:diamond_block>
// Otherwise, return <item:minecraft:clay> with a display name of "Diamond Block"
return < item : minecraft:clay > .setDisplayName( "Diamond Block" );
Recipe functions can be assigned to a variable allowing you to ulitize the same function for multiple recipes easily.
Shapeless:
import crafttweaker . api.item . IItemStack;
var exampleShapelessRecipeVarFunction as function ( usualOut as IItemStack, inputs as IItemStack [ ] ) as IItemStack = ( usualOut, inputs ) = > {
if ( inputs [ 0 ] .displayName == "totally real diamond block" ) {
return < item : minecraft:clay > .setDisplayName ( "Diamond" ) ;
// inputs[0] in exampleShapelessRecipeVarFunction will be <item:minecraft:dirt>
craftingTable . addShapeless( "shapeless_varfunc_example_1" , < item : minecraft:diamond > * 9 , [ < item : minecraft:dirt > , < item : minecraft:stick > ], exampleShapelessRecipeVarFunction);
// inputs[0] in exampleShapelessRecipeVarFunction will be <item:minecraft:cobblestone>
craftingTable . addShapeless( "shapeless_varfunc_example_2" , < item : minecraft:diamond > * 9 , [ < item : minecraft:cobblestone > , < item : minecraft:dirt > ], exampleShapelessRecipeVarFunction);
Shaped/Mirrored:
import crafttweaker . api.item . IItemStack;
var exampleShapedRecipeVarFunction as function ( usualOut as IItemStack, inputs as IItemStack [ ] [ ] ) as IItemStack = ( usualOut as IItemStack, inputs as IItemStack [ ] [ ] ) = > {
// Checks if all <item:minecraft:clay_ball> has a display name of "Diamond"
if ( < item : minecraft:clay_ball > .matches(recipeItem) && recipeItem . displayName == "Diamond" ) {
// If the recipe item is <item:minecraft:clay_ball> and has a name of "Diamond" increment the counter
// If we have 8 <item:minecraft:clay_ball> with a name of "Diamond"
if (inputs[ 1 ][ 1 ].displayName == "Special Diamond" ) {
// If <item:minecraft:diamond> has a display name of "Special Diamond"
// Return 2 <item:minecraft:diamond_block>
// Returns <item:minecraft:diamond_block>
// Otherwise, return <item:minecraft:clay> with a display name of "Diamond Block"
return < item : minecraft:clay > .setDisplayName( "Diamond Block" );
craftingTable . addShaped( "shapeed_func_example_3" , < item : minecraft:diamond_block > , [
[ < item : minecraft:clay_ball > , < item : minecraft:clay_ball > , < item : minecraft:clay_ball > ],
[ < item : minecraft:clay_ball > , < item : minecraft:diamond > , < item : minecraft:clay_ball > ],
[ < item : minecraft:clay_ball > , < item : minecraft:clay_ball > , < item : minecraft:clay_ball > ]
], exampleShapedRecipeVarFunction);
craftingTable . addShaped( "shapeed_func_example_4" , < item : minecraft:diamond_block > , [
[ < item : minecraft:clay_ball > , < item : minecraft:clay_ball > , < item : minecraft:clay_ball > ],
[ < item : minecraft:clay_ball > , < item : minecraft:diamond > , < item : minecraft:clay_ball > ],
[ < item : minecraft:clay_ball > , < item : minecraft:clay_ball > , < item : minecraft:clay_ball > ]
], exampleShapedRecipeVarFunction);
craftingTable.removeByName(recipeName);
Removes the recipe that matches the name provided.
craftingTable . removeByName ( "minecraft:sugar_from_sugar_cane" ) ;
craftingTable.remove(output);
Removes all recipes where the output result is the provided IItemStack .
craftingTable . remove ( < item : minecraft:stick > ) ;
craftingTable.removeByModid(modId);
Removes all recipes added by the provided mod.
craftingTable . removeByModid ( "minecraft" ) ;
craftingTable.removeByModid(modId, exclusionFilter);
modId
as string
exclusionFilter
as RecipeFilter
name
as string. The name of the current recipe being checked. The mod id will not be included
Removes all recipes added by the provided mod. Recipes are excluded if the result of the exclusionFilter returns true for the recipe name.
craftingTable . removeByModid ( "minecraft" , ( name ) = > {
// Checks if the name of the recipe matches "minecraft:red_bed_from_white_bed"
return name == "red_bed_from_white_bed" ;
Multiple recipes can also be excluded. One way this can be done is as follows:
// An array of recipe names as strings
var minecraftExclusions as string [] = [
"red_bed_from_white_bed" ,
craftingTable . removeByModid( "minecraft" , (name) => {
return name in minecraftExclusions;
craftingTable.removeByRegex(regex);
Removes all recipes that’s name matches the regex string.
// Removes recipes such as "minecraft:green_carpet", "minecraft:lime_carpet_from_white_carpet", and "minecraft:white_carpet"
craftingTable . removeByRegex( "minecraft:.*_carpet" );
craftingTable.removeAll();
Removes all crafting table recipes.
craftingTable . removeAll ( ) ;