Block

Make the recipe interact with blocks near the machine

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 has 4 mandatory properties and 7 optional properties.

Mandatory properties

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

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 :

"mode": "input"

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

Action

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 :

"action": "place"

The requirement will place a block.

Pos

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 :

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

The box is a 3x3x1 square behind the machine.

Optional properties

Block

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 :

"block": "minecraft:air"

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

Example :

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

Filter

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 :

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

Whitelist

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 :

"whitelist": true

The filter property will act as a whitelist.

Amount

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 :

"amount": 9

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

Comparator

Name : comparator

Description :

A Comparator 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 :

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

Delay

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 :

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

Chance

Name : chance

Description :

A double between 0.0 and 1.0 that define the chance of the command to be run.

Default : 1

The command will always be run.

Example :

"chance": 0.7

The command will have 70% chance to be run.

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

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