RecipePattern - TCreopargh/CraftTweakerIntegration GitHub Wiki

A cool new way to add recipes!

It's similar to how you register recipes using JSON.

Importing class

import mods.ctintegration.util.RecipePattern;

Methods

Method Description
static RecipePattern init(String[] recipePattern) returns a RecipePattern instance with the given pattern
static RecipePattern init(IItemStack output, String[] recipePattern)
static RecipePattern init(String name, IItemStack output, String[] recipePattern)
RecipePattern with(String character, IIngredient ingredient) maps a character to an IIngredient. the string must only contain one character!
RecipePattern and(String character, IIngredient ingredient) same as with, but cooler
RecipePattern withOutput(IItemStack output) sets the output
RecipePattern setMirrored(boolean isMirrored) sets if the recipe is mirrored
RecipePattern setName(String name) sets the recipe name
RecipePattern setShapeless(boolean isShapeless) If the reicipe is shapeless, all lines in the pattern will be combined into one line and whitespaces will be ignored
RecipePattern setFunction(IRecipeFunction function) sets the RecipeFunction
RecipePattern setFunction(IRecipeAction action) sets the RecipeAction
RecipePattern map(Map<String, IIngredient> mapping) map multiple characters at once with CraftTweaker's Map
void build() call this after everything is set up, this registers the craft table recipe you have just defined.

Zen Getters

Getter Name Return Type description
ingredients IIngredient[][] retrieves the 2d array of IIngredient from the mapping
shapelessIngredients IIngredient[] same as above but is for shapeless recipes and is an 1d array. You can call this without calling setShapeless(true)

Examples

Note that whitespace characters are mapped to null and you cannot map them to something else.


RecipePattern.init("dsdafg", <minecraft:wool>, [
    "aaa",
    "b b",
    "ccc"
])
.with('a', <minecraft:string>)
.and('b', <minecraft:stick>)
.and('c', <ore:ingotIron>)
.setMirrored(true)
.build();

RecipePattern.init(<minecraft:wool>, [
    "AAA",
    "S S",
    "GGG"
])
.map({
    A: <minecraft:apple>,
    S: <minecraft:stick>,
    G: <ore:ingotGold>
})
.setMirrored(true)
.setName("blabla")
.setAction(function(out, cInfo, player) {
    player.xp += 1;
})
.build();

Instead of registering a crafting table recipe, you can use the RecipePattern builder to build ingredient arrays which can be used in other places, like in Avaritia's 9*9 extreme crafting table:

mods.avaritia.ExtremeCrafting.addShaped("recipe_0", <minecraft:diamond>, RecipePattern.init([
    "         ",
    " ### ### ",    
    "#########",
    "#########",
    " ####### ",
    "  #####  ",
    "   ###   ",
    "    #    ",
    "         "
]).map({
    '#': <ore:ingotGold>
}).ingredients);