# Energy

Energy requirement is used to define energy inputs and outputs for a custom machine recipe.

To use it you just need to provide the amount of energy (Forge Energy aka FE) 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 specified amount of energy from the machine [energy component](https://frinn.gitbook.io/custom-machinery-1.21/creating-custom-machines/machine-components/energy-component).

In output mode : When starting to craft the recipe, the machine will produce the specified amount of energy and put it in the machine [energy component](https://frinn.gitbook.io/custom-machinery-1.21/creating-custom-machines/machine-components/energy-component).

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

### Properties

The Energy Requirement has 3 mandatory property and 1 optional property.

#### Mandatory properties

```json
"type": "custommachinery:energy" //Mandatory to define an energy requirement.
```

<details>

<summary>Mode</summary>

#### Name : `mode`

#### Description :

Define the I/O mode of the requirement.

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

#### Example :

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

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

</details>

<details>

<summary>Amount</summary>

#### Name : `amount`

#### Description :&#x20;

A positive integer value that define the amount of energy the recipe will consume/produce.&#x20;

It can be any positive number but remember that the machine [energy component](https://frinn.gitbook.io/custom-machinery-1.21/creating-custom-machines/machine-components/energy-component) must be able to store at least this amount of energy.

#### Example :&#x20;

```json
"amount": 1000
```

The recipe will consume/produce 1000FE.

</details>

#### Optional property

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

### Example

An energy requirement that will make the recipe produce 2672FE:

```json
{
    "type": "custommachinery:energy",
    "mode": "output",
    "amount": 2672
}
```

An energy requirement that will make the recipe consume 100FE with 80% chance:

```json
{
    "type": "custommachinery:energy",
    "mode": "input",
    "amount": 100,
    "chance": 0.8
}
```
