# Machine recipe

Custom machine recipe jsons must be located in `(my_datapack)/data/(namespace)/recipes/` (the same place as the vanilla recipes).

The (namespace) is a folder that can have any name, but must be all lowercase without spaces or special characters.

The machine name must be all lowercase with no spaces or any other characters than letters and numbers but you can use "\_" or "/". The file must be a .json file.

Example : `my_datapack/data/namespace/recipes/my_recipe.json`

Each recipes loaded in the game must have a different ID, in the example above the recipe Id is : namespace:my\_recipe

You can put any number of recipes under the same namespace or separate them.

You can also use subfolders like : `(my_datapack)/data/(namespace)/recipes/machine1/my_recipe.json` so the recipe ID will be `namespace:machine1/my_recipe`

Just remember that all the recipe json should be under the recipes folder.

### Recipe properties

The recipe json has 3 mandatory properties and 6 optional properties :&#x20;

#### Mandatory properties

```json5
"type": "custommachinery:custom_machine" //Mandatory for defining a custom machine recipe.
```

<details>

<summary>Machine</summary>

#### Name : `machine`

#### Description :&#x20;

The machine this recipe is for.&#x20;

You can set only one machine here so if you want the same recipe to work for different machines you must write the recipe for each machine and change this property.&#x20;

**You must use here the Machine ID and not the machine name.**

If the machine ID is wrong or the machine doesn't exist the recipe will still load but it will be unusable in-game.

#### Example :&#x20;

```json5
"machine": "namespace:my_machine"
```

This recipe will be set for the machine with ID "namespace:my\_machine".

Reminder : "namespace:my\_machine" is the machine located in `(datapack)/data/namespace/machines/my_machine.json`

</details>

<details>

<summary>Time</summary>

#### Name : `time`

#### Description :&#x20;

A positive integer that define the duration of the recipe **in ticks**.

#### Example :&#x20;

```json
"time": 200
```

The recipe will takes 10 seconds to be completed since there is 20 ticks in 1 second (if the server doesn't lag).

Note : Increasing the recipe time will increase any per-ticks input costs and outputs.

</details>

#### Optional properties

{% content-ref url="/pages/zqU1hKaofF5lpu2dVPeu" %}
[Requirements](/custom-machinery-1.18/recipes/requirements.md)
{% endcontent-ref %}

<details>

<summary>Jei</summary>

#### Name : `jei`

#### Description :&#x20;

An array of Requirements.&#x20;

The requirements are specified exactly as in the `requirements` property above.

Requirements specified here will not be processed by the machine, they will just display in the jei recipe.

**The requirements specified here will override the requirements specified in the "requirements" property, so if this property is specified only its requirements will show in jei**.

#### Default : `empty`

#### Example :&#x20;

Define 2 recipe requirements that won't be processed by the recipe, but will be the only 2 shown in the jei recipe gui.

```json
"jei": [
    {
        "type": "requirement1",
        "mode": "input"
    },
    {
        "type": "requirement2",
        "mode": "output"
    }
]
```

</details>

<details>

<summary>Priority</summary>

#### Name : `priority`

#### Description :&#x20;

An integer between -2147483648 and 2147483647 that define which recipe will be used by the machine if several recipes pass all requirement checks.&#x20;

The recipe with the highest priority will be used.&#x20;

If several recipes pass the requirement checks and have the same priority the first loaded recipe will be used, this depends of the datapack order and can be a bit random so if you want to be sure of which recipe will be used first you must use the priority property.

#### Default : 0

#### Example :&#x20;

This recipe will be loaded before any recipe with a priority < 1000.

```json
"priority": 1000
```

</details>

<details>

<summary>Jei priority</summary>

#### Name : `jeiPriority`

#### Description :&#x20;

An integer between -2147483648 and 2147483647 that define which recipe will show first in jei, recipes with higher values will show before recipes with lower values.

#### Default : 0

#### Example :&#x20;

This recipe will show in jei before any recipes with a priority < 1000.

```json
"jeiPriority": 1000
```

</details>

<details>

<summary>Error</summary>

#### Name : `error`

#### Description :&#x20;

A boolean that determine whether the recipe will error, or reset the machine when a requirement of the recipe cannot be fulfilled.

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

#### Default : `true`

#### Example :&#x20;

```json
"error": false
```

The machine will be reset if any requirement error.

</details>

<details>

<summary>Hidden</summary>

#### Name : `hidden`

#### Description :&#x20;

If true the recipe will be hidden in JEI recipe gui.

#### Default : `false`

#### Example :&#x20;

The recipe will be hidden in JEI :&#x20;

```json
"hidden": true
```

</details>

### Template

A default recipe template with all properties specified :&#x20;

```json5
{
    "type": "custommachinery:custom_machine",
    "machine": "namespace:my_machine",
    "time": 200,
    "requirements": [],
    "jei": [],
    "priority": 1000,
    "jeiPriority": 1000
}
```

### Example

A recipe that takes a diamond and turn it into energy :

```json5
{
    "type": "custommachinery:custom_machine",
    "machine": "custommachinery:my_machine",
    "time": 1000,
    "requirements": [
    {
        "type": "custommachinery:item",
        "mode": "input",
        "item": "minecraft:diamond",
        "amount": 1
    },
    {
        "type": "custommachinery:energy",
        "mode": "output",
        "amount": 1000
    }]
}
```

{% hint style="info" %}
See more recipe examples in the [test datapack](https://github.com/Frinn38/Custom-Machinery/tree/1.18.2/test_datapack/data/custommachinery/recipes).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://frinn.gitbook.io/custom-machinery-1.18/recipes/machine-recipe.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
