# Custom machines

Define a multiblock machine and its controller.

A custom machine has a definition, process recipes joined by `recipe_key`, and a crafting recipe for its controller. The controller's `hbm:custom_machine_type` component names the definition ID.

Definition file: `data/<namespace>/hbm/custom_machine/<path>.json`. See the [paper press example](https://movblock.mov/ntm-next/wiki/custom-machines/example.md) for a complete definition, process recipe and controller recipe.

## Definition fields

| Field | Meaning and default | Range |
| - | - | - |
| `recipe_key` | Process-family key matched by `hbm:custom_machine` recipes. | |
| `name` | Text component displayed as the machine name. | |
| `cells` | Structure-cell list relative to the controller. | |
| `cells.blocks` | Block ID, list of block IDs, or block tag accepted at this cell. | |
| `cells.x` | X offset from the controller. | `i32` |
| `cells.y` | Y offset from the controller. | `i32` |
| `cells.z` | Z offset from the controller. | `i32` |
| `item_in_count` (Optional) | Item input positions; default 0. | `[0, 6]` |
| `item_out_count` (Optional) | Item output positions; default 0. | `[0, 6]` |
| `fluid_in_count` (Optional) | Input tanks; default 0. | `[0, 3]` |
| `fluid_out_count` (Optional) | Output tanks; default 0. | `[0, 3]` |
| `fluid_in_cap` (Optional) | Input-tank capacity in mB; default 0. | `[0, i32::MAX]` |
| `fluid_out_cap` (Optional) | Output-tank capacity in mB; default 0. | `[0, i32::MAX]` |
| `max_power` (Optional) | HE buffer capacity; default 0. Use a nonnegative capacity. | `i64` |
| `max_heat` (Optional) | Stored-heat limit; default 0. | `[0, i32::MAX]` |
| `max_pollution_cap` (Optional) | Pollution buffer limit; default 0. | `[0, i32::MAX]` |
| `recipe_speed_mult` (Optional) | Positive divisor of recipe duration; default 1.0. | `(0, f64::MAX]` |
| `recipe_consumption_mult` (Optional) | Positive multiplier on recipe HE cost per tick; default 1.0. | `(0, f64::MAX]` |
| `generator_mode` (Optional) | Spends inputs at the start and produces energy during the run when true; default false. | |
| `flux_mode` (Optional) | Applies the recipe's flux requirement when true; default false. | |

Effective duration, truncated to an integer:

$$
\max\!\left(\frac{\mathrm{duration}}{\mathrm{recipe\_speed\_mult}},1\right)
$$

Effective HE cost per tick, truncated to a long integer:

$$
\max\!\left(\mathrm{power}\cdot\mathrm{recipe\_consumption\_mult},1\right)
$$

## Loading

Definitions load when the world opens. Reopen singleplayer or restart the server after changing one. Process and controller crafting recipes refresh with `/reload`.
