Skip to content

CraftTweaker RecipeBuilder

Rongmario edited this page Oct 11, 2023 · 3 revisions

CraftTweaker: RecipeBuilder

CraftTweaker can also be used to add new MBD recipes. The RecipeBuilder class provides a way to add recipes to a specific recipe map.

Note:

  • All scripts associated with multiblocked are required to be loaded by loader multiblocked. i.e. Put #loader multiblocked at the top of the script file.
  • RecipeBuilder only adds recipes to an existing recipe map. You still need to setup the recipe map and bind to a machine controller in Blueprint Table.

Example

#loader multiblocked

<mbd:recipe_map:steamer>.start()
    .duration(40)
    .inputItems(<ore:dirtyDustRedstone>)
    .inputFluids(<liquid:steam> * 500)
    .outputItems(<minecraft:redstone>)
    .perTick(true)
    .inputFE(50)
    .buildAndRegister();

Creates a RecipeBuilder

The start method of RecipeMap creates a new RecipeBuilder for a specific recipe map. To get a recipe map, you can directly use the recipe map bracket handler, or get one of a controller.

<mbd:recipe_map:recipe_map_name>.start()

<mbd:controller:controller_modid:controller_name>.recipeMap.start()

Inputs & Outputs

These methods below are used to add inputs and outputs to the recipe.

inputFE(int forgeEnergy)
outputFE(int forgeEnergy)
inputFE(float chance, int forgeEnergy)
outputFE(float chance, int forgeEnergy)

inputItems(IIngredient... inputs)
outputItems(IItemStack... outputs)
inputItems(float chance, IIngredient... inputs)
outputItems(float chance, IItemStack... outputs)

inputFluids(ILiquidStack... inputs)
outputFluids(ILiquidStack... outputs)
inputFluids(float chance, ILiquidStack... inputs)
outputFluids(float chance, ILiquidStack... outputs)

inputEntity(IEntityDefinition entity, @Optional IData data)
outputEntity(IEntityDefinition entity, @Optional IData data)
inputEntity(float chance, IEntityDefinition entity, @Optional IData data)
outputEntity(float chance, IEntityDefinition entity, @Optional IData data)

// Thaumcraft Aspect
// AspectStack class is added by MBD
// package: mods.thaumcraft.AspectStack
// Call the constructor to get one
// AspectStack("ordo", 20)
inputAspects(AspectStack... inputs)
outputAspects(AspectStack... outputs)
inputAspects(float chance, AspectStack... inputs)
outputAspects(float chance, AspectStack... outputs)

// Mekansim Gas
inputGas(IGasStack... inputs)
outputGas(IGasStack... outputs)
inputGas(float chance, IGasStack... inputs)
outputGas(float chance, IGasStack... outputs)

// Mekanism Heat
inputHeat(double heat)
outputHeat(double heat)
inputHeat(float chance, double heat)
outputHeat(float chance, double heat)

// Quantum Minecraft Dynamics Particle
inputParticles(ParticleStack... inputs)
outputParticles(ParticleStack... outputs)
inputParticles(float chance, ParticleStack... inputs)
outputParticles(float chance, ParticleStack... outputs)

// Botania Mana
inputMana(int mana)
outputMana(int mana)
inputMana(float chance, int mana)
outputMana(float chance, int mana)

// GregTech EU
inputEU(int eu)
outputEU(int eu)
inputEU(float chance, long eu)
outputEU(float chance, long eu)

// Lightning Craft LE
inputLE(double le)
outputLE(double le)
inputLE(float chance, double le)
outputLE(float chance, double le)

// Prodigy Tech Hot Air
// Output is not available
inputHotAir(int hotAir)
inputHotAir(float chance, int hotAir)

// Nature's Aura Aura
inputAura(int aura)
outputAura(int aura)
inputAura(float chance, int aura)
outputAura(float chance, int aura)

// Extra Utils 2 GP
inputGP(float gp)
outputGP(float gp)
inputGP(float chance, float gp)
outputGP(float chance, float gp)

// Projecte EMC
inputEMC(long emc)
outputEMC(long emc)
inputEMC(float chance, long emc)
outputEMC(float chance, long emc)

// Blood Magic LP
inputLP(int lp)
outputLP(int lp)
inputLP(float chance, int lp)
outputLP(float chance, int lp)

// Embers Ember
inputEmber(double ember)
outputEmber(double ember)
inputEmber(float chance, double ember)
outputEmber(float chance, double ember)

// Thaumic Augmentation Impetus
inputImpetus(int impetus)
outputImpetus(int impetus)
inputImpetus(float chance, long impetus)
outputImpetus(float chance, long impetus)

// Pneumatic Craft Pressure
// Output is not available
inputPressure(float pressure)
inputPressure(float chance, float pressure)

// Astral Sorcery Starlight
inputStarlight(int starlight, @Optional String constellation)
outputStarlight(int starlight, @Optional String constellation)
inputStarlight(float chance, int starlight, @Optional String constellation)
outputStarlight(float chance, int starlight, @Optional String constellation)

// Mystical Mechanics Mechanical Power
// Output is not available
// Chance is pretty much useless for this because of how mechanical power functions. Typically you should use perTick with this.
inputMystMechPower(double minimumPower)
inputMystMechPower(float chance, double minimumPower)

IO Properties

perTick(boolean perTick) marks all inputs or outputs behind the method call are executed per tick in recipe handling.

slotName(string slotName) marks all inputs or outputs behind the method call are only executed in a specific slot. It may be useful for custom single-block machines.

Repeat, they affects all recipe inputs and outputs behind them, rather than only the one next to.

.perTick(true)
.inputFE(50)
.inputLP(4)
.inputItems(<minecraft:apple>)

It will consume the apple item per tick. Remember to reset unneeded properties changes. (perTick(false) or slotName(null))

.perTick(true)
.inputFE(50)
.perTick(false)
.inputItems(<minecraft:apple>)

Recipe Properties

duration(int duration) (required):

Sets the duration of the recipe.

text(ITextComponent text) (optional)

Sets the title of the recipe, shown in GUI

name(String name) (optional)

Sets the name of the recipe. If omitted, a auto-generated string by recipe inputs and outputs will be used.

data(String key, IData) (optional)

Adds custom extra data to the recipe.

Recipe Conditions

These methods below are used to add extra condition to the recipe.

block(IBlockState state, int count)
dimension(String dimension, boolean reverse)
dimension(String dimension)
// ResourceLocation is not exposed to ZS
// biome(ResourceLocation biome, boolean reverse)
// biome(ResourceLocation biome)
rain(float level, boolean reverse)
rain(float level)
thunder(float level, boolean reverse)
thunder(float level)
posY(int min, int max, boolean reverse)
posY(int min, int max)

Builds the Recipe

When all stuff are done, remember to call buildAndRegister to build the recipe and register it to the recipe map. Otherwise, nothing will happen!

buildAndRegister();

Copy

The copy method creates and returns a copy of this recipe builder. Can be used to create a serial of recipes that share the same inputs and outputs.

Example