# Creating a custom machine

### The json file

Custom Machines json files should be located in `datapacks/<datapack>/data/<namespace>/machines/<machine>.json`

* \<datapack> : The name of your datapack, can be whatever you want.
* \<namespace> : The namespace of your machine, must be lowercase without spaces or special characters.
* \<machine> : The id of your machine, must be lowercase without spaces or special characters except "\_" and "/".

Each machines loaded in the game should have a different ID, in the example above the machine Id is : `namespace:machine`

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

You can also use subfolders like : `datapacks/datapack/data/namespace/machines/tier1/machine.json` so the machine ID will be `namespace:tier1/machine`

Just remember that all the machines json files should be under the machines folder.

### Machine properties

\
The machine json has 2 mandatory properties and 6 optional properties.

#### Mandatory properties

<details>

<summary>Name</summary>

#### Name : `name`

#### Description :

The name of the machine, not to be confused with the ID of the machine (which is the path to the machine json).&#x20;

It will be the name of both the machine item and the jei category for this machine recipes.

&#x20;It will also be displayed in The One Probe when the player is pointing the machine block.&#x20;

The specified name must be a string, any characters are allowed (as long as Minecraft can parse it), it can also be a lang key or a [Text Component](https://frinn.gitbook.io/custom-machinery-1.18/misc/text-component) to add more customization options.

#### Examples :

```json5
//Raw string
"name": "My cool machine"

//Lang key
"name": "machine.example.cool"

//Text component
"name": {
    "text": "My cool machine",
    "color": "red"
}
```

</details>

{% content-ref url="machine-appearance" %}
[machine-appearance](https://frinn.gitbook.io/custom-machinery-1.18/creating-custom-machines/machine-appearance)
{% endcontent-ref %}

#### Optional properties

<details>

<summary>Tooltips</summary>

#### Name : `tooltips`

#### Description :

A list of tooltips that will be displayed when the player cursor hover the machine item in a gui.&#x20;

The tooltips can be a raw string or a [Text Component](https://frinn.gitbook.io/custom-machinery-1.18/misc/text-component).&#x20;

Each tooltips of the list will be displayed in a new line.

#### Examples :

```json5
//Raw string
"tooltips": "That machine is really cool"

//List of strings
"tooltips": ["That machine is really cool", "Try it and see"]

//Text component
"tooltips": {
    "text": "That machine is really cool",
    "color": "red"
}

//List of text components
"tooltips": [
    {
        "text": "That machine is really cool",
        "color": "red"
    },
    {
        "text": "Try it and see",
        "bold": true
    }
]
```

</details>

{% content-ref url="machine-components" %}
[machine-components](https://frinn.gitbook.io/custom-machinery-1.18/creating-custom-machines/machine-components)
{% endcontent-ref %}

{% content-ref url="machine-gui" %}
[machine-gui](https://frinn.gitbook.io/custom-machinery-1.18/creating-custom-machines/machine-gui)
{% endcontent-ref %}

{% content-ref url="jei-recipe-gui" %}
[jei-recipe-gui](https://frinn.gitbook.io/custom-machinery-1.18/creating-custom-machines/jei-recipe-gui)
{% endcontent-ref %}

{% content-ref url="catalysts" %}
[catalysts](https://frinn.gitbook.io/custom-machinery-1.18/creating-custom-machines/catalysts)
{% endcontent-ref %}

{% content-ref url="processor" %}
[processor](https://frinn.gitbook.io/custom-machinery-1.18/creating-custom-machines/processor)
{% endcontent-ref %}

### Empty template

An empty template of a machine json with all it's properties.

{% code title="machine.json" %}

```json
{
    "name": "",
    "appearance": {},
    "tooltips": [],
    "components": [],
    "gui": [],
    "jei": [],
    "catalysts": []
}
```

{% endcode %}

### Examples

{% hint style="info" %}
You can download the test datapack [here](https://download-directory.github.io/?url=https%3A%2F%2Fgithub.com%2FFrinn38%2FCustom-Machinery%2Ftree%2F1.16.5%2Ftest_datapack).
{% endhint %}

See a few examples of custom machines in [the test datapack](https://github.com/Frinn38/Custom-Machinery/tree/1.16.5/test_datapack/data/custommachinery/machines).
