# Block

Block requirement is used to check/place/replace/break/destroy some blocks nearby the machine.

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

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

### Properties

The block requirement have 4 mandatory properties and 6 optional properties.

#### Mandatory properties

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

<details>

<summary>Mode</summary>

#### Name : `mode`

#### Description :

Define when the requirement will be processed.

* `input` The requirement will be processed at the start of the crafting process.
* `output` The requirement will be processed at the end of the crafting process.

#### Example :

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

The requirement will be processed at the start of the crafting process.

</details>

<details>

<summary>Action</summary>

#### Name : `action`

#### Description :

Define what will the requirement do. Available actions are:

* `check` Will only check for blocks that match the list defined in the `filter` property.
* `place` Will place the block specified in the `block` property.
* `replace_break` Will break any block that match the list defined in the `filter` property and replace it with the block specified in the `block` property.
* `replace_destroy` Will destroy any block that match the list defined in the `filter` property and replace it with the block specified in the `block` property.
* `break` Will break (and drop) a block that match the list defined in the `filter` property.
* `destroy` Will destroy (no drops) a block that match the list defined in the `filter` property.

`check` will check for the required block each tick of the recipe and stop the processing if it can't find the blocks.

`place`, `replace_break`, `replace_destroy`, `break`, `destroy` will do their actions on start of the processing if the `mode` property is "input" or on end of the processing if "output".

Difference between `break` and `destroy` is that break drop loots and destroy doesn't.

#### Example :

```json
"action": "place"
```

The requirement will place a block.

</details>

<details>

<summary>Pos</summary>

#### Name : `pos`

#### Description :

A box where the requirement is allowed to check/place/replace/break/destroy blocks.\
The box is specified with an array of 6 integers that define each faces position: `[left, bottom, front, right, up, back]`.\
The box is centered on the machine position, meaning that `[0, 0, 0, 0, 0, 0]` represent the machine block and `[-1, -1, -1, 1, 1, 1]` represent a 3x3 cube with the center block being the machine.

You can use the in-game box creation tool item to help creating a box.

#### Example :

```json
"pos": [-1, 0, 1, 1, 0, 3]
```

The box is a 3x3x1 square behind the machine.

</details>

#### Optional properties

<details>

<summary>Block</summary>

#### Name : `block`

#### Description :

A block id in the format `namespace:id` ex: `minecraft:furnace`.\
Some additional blockstate properties can be specified in the format `namespace:id[property1=value,property2=value]` ex: `minecraft:furnace[lit=true]`, that way the requirement will only care about vanilla furnaces that are lit, and exclude all other.

Some NBT tag can also be specified within `{tag1:value,tag2:value}`.

If you're not sure about the syntax, check the vanilla "/setblock" command. It use the same syntax and have autocompletion.

This block will be placed when using `place`, `replace_break` or `replace_destroy` action, for other actions it will be ignored.

#### Default :

```json
"block": "minecraft:air"
```

An air block. Meaning that the requirement can't place or break blocks.

#### Example :

```json
"block": "minecraft:furnace[lit=true,facing=north]"
```

The requirement will do it's action only on vanilla furnaces that are lit and placed facing the north.

</details>

<details>

<summary>Filter</summary>

#### Name : `filter`

#### Description :

A list of blocks or block tags (can be both) that can't be destroyed by the machine (used as a blacklist as default).\
The blocks must be specified the same way as in th `block` property (see above) e.g: `modid:block_id[property=value]{nbt=something}`.\
Block tags must be specified using the # prefix e.g: `#forge:stone`.

#### Default : `empty`

All blocks can be destroyed by the machine.

#### Example :

```json
"filter": ["minecraft:cobblestone", "#forge:stone"]
```

Allow all blocks but vanilla cobblestone or blocks in the #forge:stone tag to be checked or broken by the machine.

</details>

<details>

<summary>Whitelist</summary>

#### Name : `whitelist`

#### Description :

A boolean, if true the `filter` property list will be used as a whitelist of blocks that can be destroyed instead of a blacklist.

#### Default : `false`

The `filter` property will act as a blacklist.

#### Example :

```json
"whitelist": true
```

The `filter` property will act as a whitelist.

</details>

<details>

<summary>Amount</summary>

#### Name : `amount`

#### Description :

The amount of blocks to check/place/replace/break/destroy.\
All blocks must be in the box defined in the `pos` property and match the block defined in the `block` property.

#### Default : 1

The requirement will check/place/replace/break/destroy only 1 block.

#### Example :

```json
"amount": 9
```

The requirement will check/place/replace/break/destroy 9 blocks.\
If that amount is not respected the processing will not start.

</details>

<details>

<summary>Comparator</summary>

#### Name : `comparator`

#### Description :

A [Comparator](https://github.com/Frinn38/Custom-Machinery/wiki/Comparator-Mode) used only for the `check` action, the recipe will be processed only if `found_blocks_amount [comparator] specified_amount`, Where specified\_amount is defined in the `amount` property.

#### Default : `>=`

The recipe will be processed only if `found_blocks_amount >= specified_amount`.

#### Example :

```json
"comparator": "=="
```

The recipe will be processed only if `found_blocks_amount == specified_amount`.

#### Note :

With the place/replace\_break/replace\_destroy/break/destroy actions this property have no effect, the found\_blocks\_amount MUST be greater or equals to the specified\_amount or the recipe will not 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

A Block Requirement that will make the recipe destroy 1 block of full grown wheat in a 5x5x1 area behind the machine (making a harvester):

```json
{
    "type": "custommachinery:block",
    "mode": "output",
    "action": "destroy",
    "pos": [-2, 0, 1, 2, 0, 5],
    "block": "minecraft:wheat[age=7]"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://frinn.gitbook.io/custom-machinery-1.16/recipes/requirements/block.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
