> For the complete documentation index, see [llms.txt](https://frinn.gitbook.io/custom-machinery-1.21/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://frinn.gitbook.io/custom-machinery-1.21/recipes/requirements/structure.md).

# Structure

Make the recipe require a structure to be formed around the machine

Structure requirement is used to make the recipe need a structure around the machine to be processed.

The structure can be any size but blocks in unloaded chunks will not be found and the recipe will not start.

{% hint style="info" %}
To make a structure requirement without headache use the in game "Structure Creator" tool.
{% endhint %}

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

### Properties

The structure requirement has 3 mandatory properties and 3 optional properties.

#### Mandatory properties

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

<details>

<summary>Pattern</summary>

#### Name : `pattern`

#### Description :&#x20;

A list of list of string.\
Each character of the String represent a block, starting from the left and going to the right.\
Each String in the List represent a row, starting from the back and going to the front.\
Each List of String in the list represent a floor, starting from the bottom and going to the top.

**All String must have the same number of characters, and each floot must have the same number of String**

**The pattern must have exactly one 'm' character, representing the machine position.**

#### Example :&#x20;

```json
"pattern": [
    ["aaa"], 
    ["ama"], 
    ["aaa"]
]
```

A 3x3x1 vertical ring structure of the same block, around the machine block.

</details>

<details>

<summary>Keys</summary>

#### Name : `keys`

#### Description :&#x20;

A map of type : `"character": "block"`.&#x20;

The character key must be unique and can't be 'm' (reserved for the machine block).

The block is described the same way as in the "/setblock" command : `"namespace:id[property1=value,property2=value...]{tag1:value,tag2:value...}"`

The \[properties] and {tag} are optional.

**The character 'm' is already taken by the machine block and can't be used for anything else.**

Tags can also be specified using the prefix `#`. Example: `"#c:stones"`

A key can be reversed using the prefix `!`. Example: `"!stone"` (Accept any block but stone)

#### Example :&#x20;

```json
"keys": {
    "a": "minecraft:stone"
}
```

</details>

#### Optional properties

<details>

<summary>Action</summary>

#### Name : `action`

#### Description :&#x20;

Define the behavior of this structure requirement, can be any of these values :&#x20;

* `check` : Just check if the structure is present.
* `break` : Break an existing structure and drop its blocks.
* `destroy` : Destroy the structure and **do not** drop its blocks.
* `place_break` : Place the structure and drop the replaced blocks.
* `place_destroy` : Place the structure and **do not** drop the replaced blocks.

#### Default : `check`

#### Example :&#x20;

Set the structure requirement to break the structure :&#x20;

```json
"action": "break"
```

</details>

<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>Delay</summary>

#### Name : `delay`

#### Description :

A double value, between 0.0 and 1.0 that represents at which time of the recipe the requirement action must be executed.\
A delay of 0.5 represent half of the recipe, 0.25 a quarter etc...

#### Default : 0

The requirement action will be executed on start if mode is input or on end if mode is output.

#### Example :

```json
"delay": 0.33
```

The requirement action will be executed when the recipe progress time is at (approximatively) a third of the recipe total duration.

#### Note :

If delay is specified the requirement will be only executed at the specified delay, independently of the mode property.\
This property have no effect if the `action` is set to `check` as this action is executed each tick of the recipe.

</details>

### Example

How to define a structure requirement:

```json
{
    "type": "custommachinery:structure",
    "pattern": [
        [
            "sssss",
            "s   s",
            "s   s",
            "s   s",
            "sssss",
            "  m  "
        ]
    ],
    "keys": {
        "s": "minecraft:stone"
    }
}
```

Result : ![structure\_requirement](https://github.com/Frinn38/Custom-Machinery/raw/1.16.5/wiki/structure_requirement.png)
