# Durability

Durability requirement is used to damage or repair items in inputs slots.

To use it you need to provide the registry name of the item and the amount of durability you want the recipe to damage/repair.

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

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

### Properties

The durability requirement has 4 mandatory properties and 3 optional properties.

#### Mandatory properties

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

<details>

<summary>Mode</summary>

#### Name : `mode`

#### Description :

Define when the requirement will be processed and what it does.

* `input` When starting to craft the recipe, the machine will consume the desired amount of the specified item durability from the input slot they are in.
* `output` When finishing to craft the recipe, the machine will repair the desired amount of the specified item durability. The item must still be in an input slot.

#### Example :

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

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

</details>

<details>

<summary>Ingredient</summary>

#### Name : `ingredient`

#### Description :

An ingredient with one of the following syntax :&#x20;

* For items

```json
"ingredient": {
    "item": "item_id"
}
```

"item\_id" is the registry name of the item you want to be consumed 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:copper_ingot`).

* For tags

```json
"ingredient": {
    "tag": "tag_id"
}
```

"tag\_id" is a tag grouping any item that can be consumed by the recipe.

#### Example :

```json
"ingredient": {
    "item": "minecraft:diamond"
}
```

The item damaged/repaired by the recipe will be a vanilla Diamond.

#### Note :

You can see an item registry name by activating advanced infos (F3 + H in-game) and hovering the item in an inventory.

</details>

<details>

<summary>Amount</summary>

#### Name : `amount`

#### Description :

An integer that define the amount of durability you want to remove/add to the specified item.

#### Example :

```json
"amount": 16
```

The recipe will damage/repair the specified item 16 durability.

</details>

#### Optional properties

<details>

<summary>Chance</summary>

#### Name : `chance`

#### Description :

A double between 0.0 and 1.0 that define the chance of the item to be damaged if input or repaired if output, the chance is applied for the whole stack defined in this requirement.

#### Default : 1

The item will always be damaged/repaired.

#### Example :

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

The item will have 70% chance to be damaged/repaired.

</details>

<details>

<summary>Slot</summary>

#### Name : `slot`

#### Description :

The slot id of a slot you want to force the player to put the item in.\
The slot id **must be exactly the same** as the one specified in the [Item Component ID property](https://frinn.gitbook.io/custom-machinery-1.21/creating-custom-machines/machine-components/item-component#mandatory-properties) or it will not work.

#### Default : `empty`

The item can be put in any slot.

#### Example :

```json
"slot": "input1"
```

The item will be input/output only in the slot with id `input1`.

</details>

<details>

<summary>Break</summary>

#### Name : `break`

#### Description :&#x20;

Define whether the requirement can break the item when its durability is down to 0.

Otherwise the item will stay in the slot with 0 durability and will be able to be repaired by the player.

#### Default : `false`

#### Example :&#x20;

```json
"break": true
```

The requirement will break the item.

</details>

### Example

An Durability Requirement that will make the recipe damage a vanilla diamond pickaxe 50 durability points:

```json
{
    "type": "custommachinery:durability",
    "mode": "input",
    "ingredient": {
        "item": "minecraft:diamond_pickaxe"
    },
    "amount": 50
}
```
