Machine recipe

The basics of creating a custom machine recipe using json

Custom machine recipe jsons must be located in (my_datapack)/data/(namespace)/recipe/ (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/recipe/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)/recipe/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 10 optional properties :

Mandatory properties

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

Name : machine

Description :

The machine this recipe is for.

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.

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 :

"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

Time

Name : time

Description :

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

Example :

"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.

Optional properties

Requirements
Jei

Name : jei

Description :

An array of Requirements.

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 :

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

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

Name : priority

Description :

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

The recipe with the highest priority will be used.

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 :

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

"priority": 1000
Jei priority

Name : jeiPriority

Description :

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 :

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

"jeiPriority": 1000
Error

Name : error

Description :

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 :

"error": false

The machine will be reset if any requirement error.

Hidden

Name : hidden

Description :

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

Default : false

Example :

The recipe will be hidden in JEI :

"hidden": true
Appearance

Name : appearance

Description :

Allows to set a custom Machine appearance, such as a block model, light, hardness... while this recipe is processing.

All appearance properties specified here will override the default "running" properties specified in the machine json but only while this recipe is processing.

Once the recipe process finish or is stopped the machine appearance will revert to its default values.

This is only available for machine recipes and not craft recipes as their process is instantaneous.

Default :

No custom appearance specified, fallback to the "running" appearance specified in the machine json.

Example :

The machine will look like a bedrock block and be unbreakable while this recipe is processing :

"appearance": {
    "block": "bedrock",
    "hardness": -1
}
Gui

Name : gui

Description :

Allows to set some recipe specific gui elements, this can be an array or a single element.

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 instead.

Default : empty

Example :

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

"gui": [
    {
        "type": "custommachinery:slot",
        "x": 10,
        "y": 10,
        "id": "input1"
    },
    {
       "type": "custommachinery:empty",
       "id": "texture"
   } 
]
Cores

Name : cores

Description :

A list of cores that can run this recipes, in case the machine processor for this machine has more than 1 core.

If this list is empty the recipe will be able to run on any cores of the processor.

Each core is defined by an integer, 1 being the first core and <amount> being the last core.

Default : empty

Example :

The recipe will run only on the first core :

"cores": [1]
Single core

Name : single_core

Description :

A boolean value (true/false).

If set to true the recipe will run only on one core of the machine processor at a time.

The recipe will still run only on the cores specified using the "cores" property (see above) but only on 1 core at a time.

Default : false

Example :

Make the recipe run on only 1 core at a time :

"single_core": true

Template

A default recipe template with all properties specified :

{
    "type": "custommachinery:custom_machine",
    "machine": "namespace:my_machine",
    "time": 200,
    "requirements": [],
    "jei": [],
    "priority": 1000,
    "jeiPriority": 1000,
    "error": true,
    "hidden": false,
    "appearance": [],
    "gui": [],
    "cores": [],
    "single_core": false
}

Example

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

{
    "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
    }]
}

See more recipe examples in the test datapack.

Last updated