# Oil Refinery

A row needs four output fluids. Each operation consumes 100 mB of input and 5 HE; the input `amount` and pressure are ignored. The first output position is rolled once every 10 operations and is discarded when the slot cannot accept it. Among rows with the same input fluid, the last by `order` applies.

## Fields

| Field | Meaning and default | Range |
| - | - | - |
| `type` | Selects the `hbm:refinery` recipe format. | |
| `name` (Optional) | Internal lookup name; defaults to the last segment of the recipe resource path. | |
| `input_fluids` | Ordered fluid inputs with amount and pressure; defaults to an empty list. | |
| `input_fluids.type` | Registered fluid ID. | |
| `input_fluids.amount` | Amount in mB; use $[1, \mathrm{tank\ capacity}]$ for transfers because machine code casts to int. | `i64` |
| `input_fluids.pressure` (Optional) | Pressure level; default 0. | `i32` |
| `output_items` (Optional) | Fixed or weighted item-output positions; defaults to an empty list. | |
| `output_items.item ID` | Fixed output: String form for one item. | |
| `output_items.id` | Item ID in a stack object. | |
| `output_items.count` (Optional) | Stack size; default 1. | `[1, 99]` |
| `output_items.components` (Optional) | Item-component values. | |
| `output_items.chance` (Optional) | Output chance; omit for a guaranteed output. Some machines roll each item of the stack separately. | Rounds to weight `[1, 999]` of 1000 |
| `output_items.data` | Weighted choice: Stack object or an empty object for no output. | |
| `output_items.weight` | Relative selection weight; a positive total selects an output. | `[0, i32::MAX]` each; $\sum_i w_i \le \texttt{i32::MAX}$ |
| `output_fluids` | Ordered fluid outputs with amount and pressure; defaults to an empty list. | |
| `output_fluids.type` | Registered fluid ID. | |
| `output_fluids.amount` | Amount in mB; use $[1, \mathrm{tank\ capacity}]$ for transfers because machine code casts to int. | `i64` |
| `output_fluids.pressure` (Optional) | Pressure level; default 0. | `i32` |
| `order` (Optional) | Sort position within the recipe table; lower values first, default 2147483647. | `i32` |

## Example

Source path: `data/hbm/recipe/refinery/refinery.hotoil.json`

```json
{
  "type": "hbm:refinery",
  "input_fluids": [
    {
      "type": "hbm:hotoil",
      "amount": 100
    }
  ],
  "order": 0,
  "output_fluids": [
    {
      "type": "hbm:heavyoil",
      "amount": 50
    },
    {
      "type": "hbm:naphtha",
      "amount": 25
    },
    {
      "type": "hbm:lightoil",
      "amount": 15
    },
    {
      "type": "hbm:petroleum",
      "amount": 10
    }
  ],
  "output_items": [
    "hbm:sulfur"
  ]
}
```
