# Fluid

Fluid requirement is used to define fluid inputs and outputs in a custom machine recipe.

To use it you need to provide the registry name and the amount (in mB, with 1000mB being 1 Bucket of fluid) of the fluid you want the recipe to consume/produce.

This requirement is available in both `input` and `output` modes.

In input mode : When starting to craft the recipe, the machine will consume the desired amount of the specified fluid from the input tank it's in.

In output mode : When finishing to craft the recipe, the machine will produce the desired amount of the specified fluid and put it in the first disponible tank.

The requirement type of fluid requirement is : `"custommachinery:fluid".`

### Properties

The fluid requirement has 3 mandatory properties and 2 optional properties.

#### Mandatory properties

```json
"type": "custommachinery:fluid" //Mandatory to define a fluid requirement.
```

<details>

<summary>Mode</summary>

#### Name : `mode`

#### Description :

Define the I/O mode of the requirement.

* `input` The requirement will consume fluid at the start of the crafting process.
* `output` The requirement will produce fluid at the end of the crafting process.

#### Example :

```json
"mode": "input"
```

The requirement will consume fluid at the start of the crafting process.

</details>

<details>

<summary>Ingredient</summary>

#### Name : `ingredient`

#### Description :&#x20;

A sized ingredient with a syntax like this :&#x20;

```json
"ingredient": {
    "fluid": "fluid_id",
    "amount": amount
}
```

* "item" property is the registry name of the fluid you want to be consumed/produced by the recipe.

  It must be specified like `namespace:item_registry_name` with "namespace" being either "minecraft" if the item is from vanilla or a mod ID if the item is from a mod (ex : `minecraft:diamond` or `mekanism:steam`).
* If the requirement mode is `input` you can use a tag instead, by using "tag" instead of "item". Example : `"tag": "tag_id"`

**You can't use a tag if the requirement mode is output !**

#### Example :&#x20;

```json
"ingredient": {
    "fluid": "minecraft:lava",
    "amount": 1000
}
```

The fluid consumed/produced by the recipe will be vanilla lava.

```json
"ingredient": {
    "tag": "minecraft:water",
    "amount": 1000
}
```

The recipe will accept any fluid that are in the `minecraft:water` tag.

</details>

#### Optional properties

<details>

<summary>Chance</summary>

#### Name : `chance`

#### Description :

A double between 0.0 and 1.0 that define the chance of the requirement to be processed.

#### Default : 1

The requirement will always be processed.

#### Example :

```json
"chance": 0.7
```

The requirement will have 70% chance to be processed.

</details>

<details>

<summary>Tank</summary>

#### Name : `tank`

#### Description :&#x20;

The tank id of a tank you want to force the player to put the fluid in. The tank id **must be exactly the same** as the one specified in the [Fluid Component ID property](https://frinn.gitbook.io/custom-machinery-1.21/creating-custom-machines/machine-components/fluid-component#mandatory-properties) or it will not work. If the requirement mode is "output" the produced fluid will be put in the specified tank.

#### Default : `empty`

The fluid can be put in any tank.

#### Example :&#x20;

```json
"tank": "input1"
```

The fluid will be input/output only in the tank with id `input1`.

</details>

### Example

A fluid requirement that will make the custom machine recipe produce 500mB of water with 50% chance :

```json
{
    "type": "custommachinery:fluid",
    "mode": "output",
    "ingredient": {
        "fluid": "minecraft:water",
        "amount": 500
    },
    "chance": 0.5
}
```
