Mirrored Shaped Recipes
Link to mirrored-shaped-recipes
Mirrored Shaped Recipes are recipes that are very similar to normal Shaped Recipes, except that the inputs can be mirrored on specific axis (or all axis), an example of a recipe like this in the Vanilla game would be tools, like the Axe recipe below.
There is one difference between CraftTweaker mirrored recipes and Vanilla mirrored Recipes, CraftTweaker lets you define which axis the recipe is mirrored on, so not only can you mirror the recipe on the left and right side of the grid, but you can also mirror it on the top and bottom of the grid. As an example, the images below are from a single mirrored recipe that is set to mirror it on the diagonal axis.
Adding Mirrored Shaped Recipes
Link to adding-mirrored-shaped-recipes
Adding Mirrored Shaped Recipes is exactly the same as adding normal Shaped Recipes except it uses a different method, and it asks for the axis it should be mirrored on.
The basic syntax for a mirrored shaped recipe is:
// craftingTable.addShapedMirrored(recipeName as string, // mirrorAxis as MirrorAxis // output as IItemStack, // ingredients as IIngredient, // recipeFunction as @optional RecipeFunctionMatrix);
The optional RecipeFunctionMatrix at the end of the method is only needed for advanced recipe where the output changes depending on the input, an example being transferring NBT data from one of the input ingredients to the output item.
In general, most of your recipes are not going to be using the function, but it is there if you need it.
recipeName has some restrictions that should be kept in mind: 1) The name you provide is the "path" value of the name of the recipe, all recipes added through CraftTweaker will have the
crafttweaker modid as part of the name.
For example, if you provide "boat" as the name, the full recipe name will be
crafttweaker:boat. 2) It needs to be unique, using a non-unique recipe name will cause your recipe to replace the previous recipe. 3) It cannot contain spaces or colons (
:). 4) It must be all lowercased. 5) It cannot start with
"autogenerated/" as it is a reserved CraftTweaker folder.
output, something to note is that it has to be an IItemStack, passing in an IIngredient will not work, so using
<item:minecraft:diamond> | <item:minecraft:dirt> will not work as they are both IIngredients, but using
<item:minecraft:diamond> is valid and will work.
Here is an example of how to add a Mirrored Shaped recipe that will accept three Apples, one in the top left slot, one in the center middle slot and one in the top right slot and output an Arrow.
For a recipe like this, you don't need the recipe function, so it is simply left out.
Since this is a mirrored recipe, the Apples can either be placed in the top left and right slots, or the bottom left and right slots.
craftingTable.addShapedMirrored("mirrored_apples_to_arrows", MirrorAxis.ALL, <item:minecraft:arrow>, [ [<item:minecraft:apple>, <item:minecraft:air>, <item:minecraft:apple>], [<item:minecraft:air>, <item:minecraft:apple>, <item:minecraft:air>]]);
Recipe functions work exactly the same as they do on normal Shaped Recipes, with the index of the
inputs array matching the provided input, so if you put an Apple in the top left slot,
inputs will always refer to that apple regardless of where it is on the grid.