> For the complete documentation index, see [llms.txt](https://frinn.gitbook.io/custom-machinery-1.18/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://frinn.gitbook.io/custom-machinery-1.18/misc/crafting-your-machine.md).

# Crafting your machine

Add a recipe for crafting a custom machine item.

All the machines share the same item, with Id : `custommachinery:custom_machine_item` the machine the item will be linked to is defined with nbt.

The nbt key is `machine` and its value should be the machine id like: `custommachinery:power_crusher` (the namespace should always be included).

Vanilla json recipes, Crafttweaker and KubeJS have different ways to handle items nbt so I will put an example of each below.

The recipe will be: ![recipe](https://github.com/Frinn38/Custom-Machinery/raw/1.16.5/wiki/machine_recipe.png)

{% tabs %}
{% tab title="Vanilla json" %}
{% code title="recipe.json" %}

```json
{
    "type": "minecraft:crafting_shaped",
    "pattern":
    [
        "xxx",
        "x x",
        "xxx"
    ],
    "key":
    {
        "x":
        {
            "item": "minecraft:diamond"
        }
    },
    "result":
    {
        "item": "custommachinery:custom_machine_item",
        "count": 1,
        "nbt": {"machine":"custommachinery:power_crusher"}
    }
}
```

{% endcode %}
{% endtab %}

{% tab title="Crafttweaker script" %}
{% code title="script.zs" %}

```
craftingTable.addShaped("power_crusher", <item:custommachinery:custom_machine_item>.withTag({machine: "custommachinery:power_crusher" as string}), [
    [<item:minecraft:diamond>, <item:minecraft:diamond>, <item:minecraft:diamond>],
    [<item:minecraft:diamond>, <item:minecraft:air>, <item:minecraft:diamond>],
    [<item:minecraft:diamond>, <item:minecraft:diamond>, <item:minecraft:diamond>]
]);
```

{% endcode %}
{% endtab %}

{% tab title="KubeJS script" %}
{% code title="script.js" %}

```javascript
onEvent('recipes', e => {
    event.shaped(Item.of('custommachinery:custom_machine_item', {machine:"custommachinery:power_crusher"}), [
        'DDD',
        'D D',
        'DDD'
    ], {
        'D': 'minecraft:diamond'
    })
})
```

{% endcode %}
{% endtab %}
{% endtabs %}
