# Recipes

Custom machine recipes can be made with Crafttweaker.

Create a .zs file in the `scripts` folder (ex: `custom_machine_recipes.zs`).

Then inside the .zs file you can use either `<recipetype:custommachinery:custom_machine>.create(machine, time)` or\
`<recipetype:custommachinery:custom_craft>.create(machine, output)`

Add some requirements to the builder then call `.build();` to register the recipe.

You can also use `.build(recipe_name);` to register the recipe with a custom name.\
The recipe name can be any string in lowercase and without whitespace or special characters. Also two recipes can't have the same name.

#### Machine Recipe :&#x20;

```java
//Create the builder
<recipetype:custommachinery:custom_machine>.create("namespace:machine_id", 20)
// Add requirements here
.build(); //Build and register the recipe
.build(recipe_name); //Same as above but you can set a custom recipe name.
```

#### Craft recipe :&#x20;

```java
//Create the builder
<recipetype:custommachinery:custom_craft>.create("namespace:machine_id", <item:minecraft:diamond>)
// Add requirements here
.build(); //Build and register the recipe
.build(recipe_name); //Same as above but you can set a custom recipe name.
```

🔴**DON'T FORGET THE SEMICOLON ";" AFTER THE BUILD METHOD**🔴

### Requirements

You can add various requirements by calling the methods below directly on the custom machine recipe builder.

<details>

<summary>Item</summary>

**Use one of these methods to add an** [**Item Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/item) **to the recipe.**

```java
.requireItem(IItemStack item)
.requireItem(IItemStack item, String slot)

.requireItemTag(Tag tag)
.requireItemTag(Tag tag, int amount)
.requireItemTag(Tag tag, int amount, IData nbt)
.requireItemTag(Tag tag, int amount, IData nbt, String slot)

.produceItem(IItemStack item)
.produceItem(IItemStack item, String slot)
```

* The `item` param must be an [IItemStack](https://docs.blamejared.com/1.16/en/vanilla/api/items/IItemStack/). \
  Example : `<item:minecraft:diamond> * 5`
* The `slot` param must be a string corresponding to a slot id defined in a custom machine json [Item Component](https://frinn.gitbook.io/custom-machinery-1.19/creating-custom-machines/machine-components/item-component) `slot` property.\
  It is optional and the default value is `""` (no specific slot required).
* The `tag` param must be a [CT item tag brackets](https://docs.blamejared.com/1.16/en/tutorial/IntroductionToScripting/WhatAreBracketHandlers/#tag-format). Example : `<tag:items:forge:stone>`
* The `amount` param must be a positive integer.
* The `nbt` param must be a [IData](https://docs.blamejared.com/1.16/en/vanilla/api/data/IData/). Example : `{tag1: 1}`.\
  It is optional and the default value is no tag required.\
  This param **MUST** be specified if you want to use the `slot` param after.

</details>

<details>

<summary>Item transform</summary>

**Use one of these methods to add an** [**Item transform requirement**](#item-1) **to the recipe.**

```java
.transformItem(IItemStack input)
.transformItem(IItemStack input, IItemStack output)
.transformItem(IItemStack input, IItemStack output, String inputSlot)
.transformItem(IItemStack input, IItemStack output, String inputSlot, String outputSlot)
.transformItem(IItemStack input, IItemStack output, String inputSlot, String outputSlot, nbt as MapData => {return nbt;})

.transformItemTag(Tag tag)
.transformItemTag(Tag tag, int inputAmount)
.transformItemTag(Tag tag, int inputAmount, IData inputNBT)
.transformItemTag(Tag tag, int inputAmount, IData inputNBT, IItemStack output)
.transformItemTag(Tag tag, int inputAmount, IData inputNBT, IItemStack output, String inputSlot)
.transformItemTag(Tag tag, int inputAmount, IData inputNBT, IItemStack output, String inputSlot, String outputSlot)
.transformItemTag(Tag tag, int inputAmount, IData inputNBT, IItemStack output, String inputSlot, String outputSlot, nbt as MapData => {return nbt;})
```

* The `input and output`params must be an [IItemStack](https://docs.blamejared.com/1.16/en/vanilla/api/items/IItemStack/). \
  Example : `<item:minecraft:diamond> * 5`
* The `inputSlot` and `outputSlot` params must be a string corresponding to a slot id defined in a custom machine json [Item Component](https://frinn.gitbook.io/custom-machinery-1.19/creating-custom-machines/machine-components/item-component) `slot` property.\
  It is optional and the default value is `""` (no specific slot required).
* The `tag` param must be a [CT item tag brackets](https://docs.blamejared.com/1.16/en/tutorial/IntroductionToScripting/WhatAreBracketHandlers/#tag-format). Example : `<tag:items:forge:stone>`
* The `inputAmount` param must be a positive integer.
* The `inputNBT` param must be a [IData](https://docs.blamejared.com/1.16/en/vanilla/api/data/IData/). Example : `{tag1: 1}`.\
  It is optional and the default value is no tag required.\
  This param **MUST** be specified if you want to use the `slot` param after.
* The last param can be a function that takes a [MapData ](https://docs.blamejared.com/1.18/en/vanilla/api/data/MapData)which is the nbt of the input item (**Warning: it can be null**), and must return a [MapData ](https://docs.blamejared.com/1.18/en/vanilla/api/data/MapData)which will be set as the nbt of the output item.

</details>

<details>

<summary>Durability</summary>

**Use one of these methods to add a** [**Durability Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/durability) **to the recipe.**

```java
.damageItem(IItemStack item, int amount)
.damageItem(IItemStack item, int amount, String slot)

//Don't break the item if its durability reach 0
.damageItemNoBreak(IItemStack item, int amount)
.damageItemNoBreak(IItemStack item, int amount, String slot)

.damageItemTag(Tag tag, int amount)
.damageItemTag(Tag tag, int amount, IData nbt)
.damageItemTag(Tag tag, int amount, IData nbt, String slot)

//Don't break the item if its durability reach 0
.damageItemTagNoBreak(Tag tag, int amount)
.damageItemTagNoBreak(Tag tag, int amount, IData nbt)
.damageItemTagNoBreak(Tag tag, int amount, IData nbt, String slot)

.repairItem(IItemStack item, int amount)
.repairItem(IItemStack item, int amount, String slot)

.repairItemTag(Tag tag, int amount)
.repairItemTag(Tag tag, int amount, IData nbt)
.repairItemTag(Tag tag, int amount, IData nbt, String slot)
```

* The `item` param must be an [IItemStack](https://docs.blamejared.com/1.16/en/vanilla/api/items/IItemStack/). \
  Example : `<item:minecraft:diamond> * 5`
* The `slot` param must be a string corresponding to a slot id defined in a custom machine json [Item Component](https://frinn.gitbook.io/custom-machinery-1.19/creating-custom-machines/machine-components/item-component) `slot` property.\
  It is optional and the default value is `""` (no specific slot required).
* The `tag` param must be a [CT item tag brackets](https://docs.blamejared.com/1.16/en/tutorial/IntroductionToScripting/WhatAreBracketHandlers/#tag-format). Example : `<tag:items:forge:stone>`
* The `amount` param must be a positive integer.
* The `nbt` param must be a [IData](https://docs.blamejared.com/1.16/en/vanilla/api/data/IData/). Example : `{tag1: 1}`.\
  It is optional and the default value is no tag required.\
  This param **MUST** be specified if you want to use the `slot` param after.

</details>

<details>

<summary>Fluid</summary>

**Use one of these methods to add a** [**Fluid Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/fluid) **to the recipe.**

```java
.requireFluid(Fluid fluid, long amount)
.requireFluid(Fluid fluid, long amount, IData data)
.requireFluid(Fluid fluid, long amount, IData data, String slotID)

.requireFluidTag(Tag tag, int amount)
.requireFluidTag(Tag tag, int amount, IData nbt)
.requireFluidTag(Tag tag, int amount, IData nbt, String tank)

.produceFluid(Fluid fluid, long amount)
.produceFluid(Fluid fluid, long amount, IData data)
.produceFluid(Fluid fluid, long amount, IData data, String slotID)

.requireFluidPerTick(Fluid fluid, long amount)
.requireFluidPerTick(Fluid fluid, long amount, IData data)
.requireFluidPerTick(Fluid fluid, long amount, IData data, String slotID)

.requireFluidTagPerTick(Tag tag, int amount)
.requireFluidTagPerTick(Tag tag, int amount, IData nbt)
.requireFluidTagPerTick(Tag tag, int amount, IData nbt, String tank)

.produceFluidPerTick(Fluid fluid, long amount)
.produceFluidPerTick(Fluid fluid, long amount, IData data)
.produceFluidPerTick(Fluid fluid, long amount, IData data, String slotID)
```

* The `fluid` param must be a CT [Fluid](https://docs.blamejared.com/1.18/en/vanilla/api/fluid/Fluid). \
  Example : `<fluid:minecraft:water>`
* The `amount` param must be a positive long.
* The `nbt` param must be a [IData](https://docs.blamejared.com/1.16/en/vanilla/api/data/IData/). Example : `{tag1: 1}`.\
  If you don't want the item to have a nbt you can pass `null`.
* The `tank` param must be a string corresponding to a tank id defined in a custom machine json [Fluid Component](https://frinn.gitbook.io/custom-machinery-1.19/creating-custom-machines/machine-components/fluid-component) `tank` property.\
  It is optional and the default value is no specific slot.
* The `tag` param must be a [CT fluid tag brackets](https://docs.blamejared.com/1.16/en/tutorial/IntroductionToScripting/WhatAreBracketHandlers/#tag-format). Example : `<tag:fluids:minecraft:water>`

</details>

<details>

<summary>Energy</summary>

**Use one of these methods to add an** [**Energy Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/energy) **to the recipe.**

```java
.requireEnergy(int amount)

.requireEnergyPerTick(int amount)

.produceEnergy(int amount)

.produceEnergyPerTick(int amount)
```

* The `amount` param must be a positive integer.

</details>

<details>

<summary>Time</summary>

**Use one of these methods to add a** [**Time Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/time) **to the recipe.**

```java
.requireTime(String time)
```

* The `time` param must be a string that represent a time [Range](https://frinn.gitbook.io/custom-machinery-1.19/misc/range). \
  Look at the [Time Requirement](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/time) wiki page to know what to put here.

</details>

<details>

<summary>Position</summary>

**Use one of these methods to add a** [**Position Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/position) **to the recipe.**

```java
.requirePosition(String x, String y, String z)
```

* The `x`, `y` and `z` params must be a valid [range](https://frinn.gitbook.io/custom-machinery-1.19/misc/range). Use `""` if you want to allow any value for an axis.

</details>

<details>

<summary>Biome</summary>

**Use one of these methods to add a** [**Biome Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/biome) **to the recipe.**

```java
.biomeWhitelist(Biome biome)
.biomeWhitelist(Biome[] biomes)

.biomeBlacklist(Biome biome)
.biomeBlacklist(Biomes[] biomes)
```

* The `biome` param must be a [biome brackets](https://docs.blamejared.com/1.16/en/vanilla/api/BracketHandlers/#g-getbiome). \
  Example : `<biome:minecraft:ocean>`

</details>

<details>

<summary>Dimension</summary>

#### **Use one of these methods to add a** [Dimension **Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/dimension) **to the recipe.**

```java
.dimensionWhitelist(String dimension)
.dimensionWhitelist(String[] dimensions)

.dimensionBlacklist(String dimension)
.dimensionBlacklist(String[] dimensions)
```

* The `dimension` param must be a string defining a valid dimension id. \
  Example : `minecraft:overworld`

</details>

<details>

<summary>Fuel</summary>

**Use this method to add a** [**Fuel Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/fuel) **to the recipe.**

```java
.requireFuel()

.requireFuel(int amount)
```

* The `amount` param must be a positive integer that define the amount of fuel burned each tick of the recipe processing.\
  Default to 1 when not specified.

</details>

<details>

<summary>Command</summary>

**Use one of these methods to add a** [**Command Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/command) **to the recipe.**

```java
.runCommandOnStart(String command)
.runCommandOnStart(String command, int permissionLevel)
.runCommandOnStart(String command, int permissionLevel, boolean log)

.runCommandEachTick(String command)
.runCommandEachTick(String command, int permissionLevel)
.runCommandEachTick(String command, int permissionLevel, boolean log)

.runCommandOnEnd(String command)
.runCommandOnEnd(String command, int permissionLevel)
.runCommandOnEnd(String command, int permissionLevel, boolean log)
```

* The `command` param must be a string starting by `/` which will be run as a command.
* The `permissionLevel` param must be a positive integer. \
  Default : `2`
* The `log` param must be a boolean, if true the command will be logged in admin chat as a system command. \
  Default : `false`

</details>

<details>

<summary>Effect</summary>

**Use one of these methods to add an** [**Effect Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/effect) **to the recipe.**

```java
.giveEffectOnEnd(Effect effect, int time, int radius)
.giveEffectOnEnd(Effect effect, int time, int radius, int level)
.giveEffectOnEnd(Effect effect, int time, int radius, int level, Entity[] filter)

.giveEffectEachTick(Effect effect, int time, int radius)
.giveEffectEachTick(Effect effect, int time, int radius, int level)
.giveEffectEachTick(Effect effect, int time, int radius, int level, Entity[] filter)
```

* The `effect` param must be a [Effect brackets](https://docs.blamejared.com/1.16/en/vanilla/api/BracketHandlers/#g-geteffect). \
  Example : `<effect:minecraft:regeneration>`
* The `time` and `radius` params must be a positive integer.
* The `level` param must be a positive integer. Default : `1`
* The `filter` param must be an array of [entity types](https://docs.blamejared.com/1.16/en/vanilla/api/BracketHandlers/#g-getentitytype). \
  Example : `[<entitytype:minecraft:cow>, <entitytype:minecraft:pig>"]` Default : `[]`

</details>

<details>

<summary>Weather</summary>

**Use one of these methods to add a** [**Weather Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/weather) **to the recipe.**

```java
.requireWeather(String weather)

.requireWeatherOnMachine(String weather)
```

* The `weather` param must be a string defining the required weather. \
  Valid values : `clear`, `rain`, `snow`, `thunder`

</details>

<details>

<summary>Redstone</summary>

**Use one of these methods to add a** [**Redstone Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/redstone) **to the recipe.**

```java
.requireRedstone(String power)
```

* The `power` param must be a valid [range](https://frinn.gitbook.io/custom-machinery-1.19/misc/range) that define the acceptable redstone signals to start the recipe.

</details>

<details>

<summary>Light</summary>

**Use one of these methods to add a** [**Light Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/light) **to the recipe.**

```java
.requireSkyLight(int amount)
.requireSkyLight(String range)

.requireBlockLight(int amount)
.requireBlockLight(String range)
```

* The `amount` param must be a positive integer between 0 and 15.
* The `range` param must be a string defining a valid [Range](https://frinn.gitbook.io/custom-machinery-1.19/misc/range).

</details>

<details>

<summary>Entity</summary>

**Use one of these methods to add an** [**Entity Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/entity) **to the recipe.**

```java
.requireEntities(int amount, int radius, Entity[] filter, boolean whitelist)

.requireEntityHealth(int amount, int radius, Entity[] filter, boolean whitelist)

.consumeEntityHeathOnStart(int amount, int radius, Entity[] filter, boolean whitelist)

.consumeEntityHealthOnEnd(int amount, int radius, Entity[] filter, boolean whitelist)

.killEntitiesOnStart(int amount, int radius, Entity[] filter, boolean whitelist)

.killEntitiesOnEnd(int amount, int radius, Entity[] filter, boolean whitelist)
```

* The `amount` and `radius` params must be a positive integer.
* The `filter` param must be an array of [entity types](https://docs.blamejared.com/1.16/en/vanilla/api/BracketHandlers/#g-getentitytype). Example : `[<entitytype:minecraft:cow>, <entitytype:minecraft:pig>"...]` Default : `[]`
* The `whitelist` param must be a boolean, if true the filter will be a whitelist, if false it will be a blacklist.

</details>

<details>

<summary>Block</summary>

**Use one of these methods to add a** [**Block Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/block) **to the recipe.**

```java
.requireBlock(filter, whitelist, startX, startY, startZ, endX, endY, endZ)
.requireBlock(filter, whitelist, startX, startY, startZ, endX, endY, endZ, amount)
.requireBlock(filter, whitelist, startX, startY, startZ, endX, endY, endZ, amount, comparator)

.placeBlockOnStart("block", startX, startY, startZ, endX, endY, endZ)
.placeBlockOnStart("block", startX, startY, startZ, endX, endY, endZ, amount)

.placeBlockOnEnd("block", startX, startY, startZ, endX, endY, endZ)
.placeBlockOnEnd("block", startX, startY, startZ, endX, endY, endZ, amount)

.breakAndPlaceBlockOnStart("block", startX, startY, startZ, endX, endY, endZ)
.breakAndPlaceBlockOnStart("block", startX, startY, startZ, endX, endY, endZ, amount)
.breakAndPlaceBlockOnStart("block", startX, startY, startZ, endX, endY, endZ, amount, filter)
.breakAndPlaceBlockOnStart("block", startX, startY, startZ, endX, endY, endZ, amount, filter, whitelist)

.breakAndPlaceBlockOnEnd("block", startX, startY, startZ, endX, endY, endZ)
.breakAndPlaceBlockOnEnd("block", startX, startY, startZ, endX, endY, endZ, amount)
.breakAndPlaceBlockOnEnd("block", startX, startY, startZ, endX, endY, endZ, amount, filter)
.breakAndPlaceBlockOnEnd("block", startX, startY, startZ, endX, endY, endZ, amount, filter, whitelist)

.destroyAndPlaceBlockOnStart("block", startX, startY, startZ, endX, endY, endZ)
.destroyAndPlaceBlockOnStart("block", startX, startY, startZ, endX, endY, endZ, amount)
.destroyAndPlaceBlockOnStart("block", startX, startY, startZ, endX, endY, endZ, amount, filter)
.destroyAndPlaceBlockOnStart("block", startX, startY, startZ, endX, endY, endZ, amount, filter, whitelist)

.destroyAndPlaceBlockOnEnd("block", startX, startY, startZ, endX, endY, endZ)
.destroyAndPlaceBlockOnEnd("block", startX, startY, startZ, endX, endY, endZ, amount)
.destroyAndPlaceBlockOnEnd("block", startX, startY, startZ, endX, endY, endZ, amount, filter)
.destroyAndPlaceBlockOnEnd("block", startX, startY, startZ, endX, endY, endZ, amount, filter, whitelist)

.destroyBlockOnStart(filter, whitelist, startX, startY, startZ, endX, endY, endZ)
.destroyBlockOnStart(filter, whitelist, startX, startY, startZ, endX, endY, endZ, amount)

.destroyBlockOnEnd(filter, whitelist, startX, startY, startZ, endX, endY, endZ)
.destroyBlockOnEnd(filter, whitelist, startX, startY, startZ, endX, endY, endZ, amount)

.breakBlockOnStart(filter, whitelist, startX, startY, startZ, endX, endY, endZ)
.breakBlockOnStart(filter, whitelist, startX, startY, startZ, endX, endY, endZ, amount)

.breakBlockOnEnd(filter, whitelist, startX, startY, startZ, endX, endY, endZ)
.breakBlockOnEnd(filter, whitelist, startX, startY, startZ, endX, endY, endZ, amount)
```

* The `block` param must be a string defining a valid blockstate.\
  Using the format `namespace:block_id[property1=value1,property2=value2...]{tag1: value1, tag2: value2...}` (The \[] and {} are optional)\
  This is the block that will be placed.
* The `filter` param must be an arrays of string defining a valid blockstate.\
  This is the blocks that the machine can/can't break depending on the whitelist property.
* The `whitelist` param must be a boolean, if true the filter property will be a whitelist, if false a blacklist. Default to false when not specified.
* The `startX`, `startY`, `startZ`, `endX`, `endY`, `endZ` must be integer values defining the box where the machine will search for blocks.\
  You can use the in-game `Box Creator` to select a box and put the values here.
* The `amount` param must be a positive integer. \
  Default : `1`
* The `comparator` param must be a string defining a valid [Comparator Mode](https://frinn.gitbook.io/custom-machinery-1.19/misc/comparator). \
  Default : `==`

</details>

<details>

<summary>Loot Table</summary>

**Use one of these methods to add a** [**Loot Table Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/loot-table) **to the recipe.**

```java
.lootTableOutput(String loot_table)

.lootTableOutput(String loot_table, float luck)
```

* The `loot_table` param must be a string path that point to a loot table. The loot table file must be loaded with a datapack or a loader mod.\
  Example: `custommachinery:my_test_loottable` point to a file in `data/custommachinery/loot_tables/my_test_loottable.json`
* The `luck` param must be a float. \
  Default is 0.0 and it can be used in the loot table to alter the quantity of generated items.

</details>

<details>

<summary>Drop</summary>

**Use one of these methods to add a** [**Drop Requirement**](https://frinn.gitbook.io/custom-machinery-1.19/recipes/requirements/drop) **to the recipe.**

```java
//Check for a specific item.
.checkDrop(IItemStack item, int amount, int radius)
//Check for any item.
.checkAnyDrop(int amount, int radius)
//Check for a list of items.
.checkDrops(IItemStack[] filter, int amount, int radius)
.checkDrops(IItemStack[] filter, int amount, int radius, boolean whitelist)

.consumeDropOnStart(IItemStack item, int amount, int radius)
//Consume any drop at the end of the recipe.
.consumeDropOnStart(int amount, int radius)
.consumeDropsOnStart(IItemStack[] filter, int amount, int radius)
.consumeDropsOnStart(IItemStack[] filter, int amount, int radius, boolean whitelist)

.consumeDropOnEnd(IItemStack item, int amount, int radius)
//Consume any drop at the end of the recipe.
.consumeDropOnEnd(int amount, int radius)
.consumeDropsOnEnd(IItemStack[] filter, int amount, int radius)
.consumeDropsOnEnd(IItemStack[] filter, int amount, int radius, boolean whitelist)

.dropItemOnStart(IItemStack item)
.dropItemOnEnd(IItemStack item)
```

* The `item` param must be an [IItemStack](https://docs.blamejared.com/1.16/en/vanilla/api/items/IItemStack/). \
  Example : `<item:minecraft:diamond> * 5`
* The `amount` param must be a positive integer, it represents the amount of items checked/consumed.
* The `radius` param must be a positive integer, it represents the maximum distance to the machine the items will be searched.
* The `filter` param must be an array of [IItemStack](https://docs.blamejared.com/1.16/en/vanilla/api/items/IItemStack/). \
  Example : `[<item:minecraft:diamond> * 5, <item:minecraft:cobblestone>]`. \
  It represents a whitelist of items to search.
* The `whitelist` param must be a boolean, if set to `false` the filter will be a blacklist instead of a whitelist.

</details>

{% content-ref url="recipes/function" %}
[function](https://frinn.gitbook.io/custom-machinery-1.19/mod-integrations/crafttweaker/recipes/function)
{% endcontent-ref %}

{% content-ref url="recipes/sky" %}
[sky](https://frinn.gitbook.io/custom-machinery-1.19/mod-integrations/crafttweaker/recipes/sky)
{% endcontent-ref %}

### Requirements special properties

Some requirements (almost all) have various properties that can change its behavior.

To set these properties you must call one or several of the methods below **immediately after** the desired requirement. The properties will only be applied on the latest added requirement when the method is called.

If the latest added requirement doesn't support the property an error will be logged and nothing will happen (the property will be ignored).

<details>

<summary>Chance</summary>

**Use this method to add a `chance` property to the latest added requirement.**

```java
.chance(double chance)
```

* The `chance` param must be a double between 0.0 and 1.0 included.

**Supported requirements :**

* Block
* Command
* Drop
* Durability
* Effect
* Energy
* Energy Per Tick
* Entity
* Fluid
* Fluid Per Tick
* Function
* Item

</details>

<details>

<summary>Delay</summary>

**Use this method to set a delay for the requirement action.**

The requirement will only execute its action after the specified delay.

```java
.delay(double delay)
```

* The `delay` param must be a double between 0.0 and 1.0 excluded. 0 represent the start of the recipe and 1 represent its end.

**Supported requirements :**

* Block
* Command
* Drop
* Effect
* Entity
* Function

</details>

<details>

<summary>Display info</summary>

Specify a custom requirement display info by calling the following method after a requirement :&#x20;

```javascript
.info(info => info
    //Add a new tooltip line
    .tooltip("A new tooltip")
    //This line will be displayed for creative players only
    .tooltip("Creative only", "creative")
    //This line will be displayed for players with F3+H only
    .tooltip("Advanced debug info only", "advanced")
    //Use an item as icon
    .item(<item:minecraft:diamond>)
    //Use one of these 3 methods to specify a texture as icon
    .texture("texture_path")
    .texture("texture_path", width, height)
    .texture("texture_path", width, height, u, v)
    //Use a sprite as icon
    .sprite("atlas_path", "sprite_id")
)
```

Example : Add a diamond icon with a tooltip

```javascript
.info(info => info.tooltip("This recipe make diamonds").item(<item:minecraft:diamond>))
```

![](https://2254391542-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F40ngT44k0ZSkP7lvRktf%2Fuploads%2Fp7ox4iRSpYacBioszYTC%2Fimage.png?alt=media\&token=e0ed5d15-42aa-4feb-a1b7-6547e947b2d6)

</details>

### Priority

Use the method below to set the priority of the recipe.

If this method is called several times only the latest will be used.

If this is called **AFTER** `.jei()` (no need to be immediately after) this will act as the "jeiPriority" instead, defining the priority of the recipe to show in jei instead of the priority to be checked in the machine.

If no priority is set, the default value : `0` will be used.

```java
.priority(priority)
```

* The `priority` param must be an integer value.

### Jei

If the method below is called, all requirements added after that will be added to the `jei` property requirement list.

```java
.jei()
```

This action cannot be inverted, you must add all your recipe requirements before calling it.

Requirements added after this method will only be displayed in jei but not executed by the machine. Learn more [here](https://frinn.gitbook.io/custom-machinery-1.19/recipes/machine-recipe#optional-properties).

### Reset on error

If the method below is called, the recipe will reset the machine instead of erroring when a requirement throw an error.

```javascript
.resetOnError()
```

Note : When the machine is reset its inventory remains the same, but all already consumed inputs are lost.

### Hide in JEI

Call the following method anywhere in your recipe builder (between `.create()` and `.build();`) to make the recipe hidden in JEI.

The recipe will still work in the machine but won't show in JEI.

```javascript
.hide()
```

### Custom machine appearance

The following methods allow you to set a custom machine appearance that will be applied on the machine while this recipe is processing.

Each of the following properties are optional, just call those you need.

```javascript
.appearance(builder => builder
        .block('block_id')
        .item('item_id') //Useless
        .ambientSound('sound_id')
        .interactionSound('block_id')
        .light(light_level) //Between 0 and 15
        .color(color_integer) //Only integer color here
        .hardness(hardness) //Can be -1 for unbreakable
        .resistance(resistance)
        .tooltype('tool_type') //Must be a block tag id
        .miningLevel('mining_level') //Must be a block tag id
        .requiresTool(required) //True/False
)
```

### Custom machine gui

The following method allows you to add or replace some of the machine's gui elements while this recipe is processing.

```javascript
.gui([...])//Replace '...' by your gui elements.
```

Any gui element from CM and its addons can be used here.

When a machine process this recipe, all gui elements defined here will be added to the machine gui.

If a gui element defined here has the same id than another element defined in the machine json then it will replace it.

It is impossible to remove a gui element defined in the machine json, but you can replace it with an [empty gui element](https://frinn.gitbook.io/custom-machinery-1.19/creating-custom-machines/machine-gui/empty-element) instead.

#### Example :&#x20;

Change the position of a slot gui element with id "input1", and replace the gui element with id "texture" by an empty gui element :&#x20;

```javascript
.gui([
    {
        "type": "custommachinery:slot",
        "x": 10,
        "y": 10,
        "id": "input1"
    },
    {
       "type": "custommachinery:empty",
       "id": "texture"
    }
])
```

### Examples :

<details>

<summary>Example 1</summary>

**A 100 tick recipe that use 5mB of water, 5mB of any fluid with tag lava and 20FE per tick to create a stone.**

```java
mods.custommachinery.CMRecipeBuilder.create("custommachinery:stone_generator", 100)
.requireFluid(<fluid:minecraft:water> * 5)
.requireFluidTag(<tag:fluids:minecraft:lava>, 5)
.requireEnergyPerTick(20)
.produceItem(<item:minecraft:stone>)
.build();
```

<img src="https://github.com/Frinn38/Custom-Machinery/raw/1.16.5/wiki/example_recipe_1.png" alt="example_recipe_1" data-size="original">

</details>

<details>

<summary>Example 2</summary>

**A 200 tick recipe that use 1 item with tag stone and 20FE per tick to create 1 cobblestone, 1 gravel with 50% chance and 1 sand with 10% chance.**

```java
mods.custommachinery.CMRecipeBuilder.create("custommachinery:power_crusher", 200)
.requireItemTag(<tag:items:forge:stone>, 1)
.requireEnergyPerTick(20)
.produceItem(<item:minecraft:cobblestone>)
.produceItem(<item:minecraft:gravel>).chance(0.5)
.produceItem(<item:minecraft:sand>).chance(0.1)
.build();
```

<img src="https://github.com/Frinn38/Custom-Machinery/raw/1.16.5/wiki/example_recipe_2.png" alt="example_recipe_2" data-size="original">

</details>
