> For the complete documentation index, see [llms.txt](https://frinn.gitbook.io/custom-machinery-1.19/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.19/recipes/requirements/command.md).

# Command

Command requirement is used to make the custom machine execute commands while crafting.

This requirement doesn't have a mode and will not stop the processing of a recipe even if the command fail.

The command can be executed at the start, at the end or every tick of the crafting process (see the `phase` property below).

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

### Properties

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

#### Mandatory properties

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

<details>

<summary>Command</summary>

#### Name : `command`

#### Description :

A string which represent the command to run, it must have the same syntax as when you run command in the chat (so begin with "/").

#### Example :

```json
"command": "/time set 0"
```

The machine's world time will be set to 0.

</details>

<details>

<summary>Phase</summary>

#### Name : `phase`

#### Description :

A string that define when the command will be executed. Available phases are:

* `starting` : The command will be executed at the start of the crafting process after all input requirements have been processed.
* `crafting_tickable` : The command will be executed each tick of the crafting process.
* `ending` : The command will be executed at the end of the crafting process after all output requirements have been processed.

#### Example :

```json
"phase": "starting"
```

The command will be executed when the process start.

</details>

#### Optional properties

<details>

<summary>Permission level</summary>

#### Name : `permissionlevel`

#### Description :

An integer that define the permission level the machine can run the command.\
In vanilla a player have a permission level of 1 and an op player have 4, see [here](https://nodecraft.com/support/games/minecraft/how-to-set-a-player-as-op-admin) for more infos.

#### Default : 2

Should be good enough to execute most commands.

#### Example :

```json
"permissionlevel": 4
```

The machine will run the command as an op.

</details>

<details>

<summary>Log</summary>

#### Description :

A boolean (true/false) that define if the machine should log the command when executed, if true a system message in the chat, console and logs will be shown.\
It can be used for debug.

#### Default : `false`

No logs, the machine will print a message in the logs only when it fail to execute a command but never in the chat.

#### Example :

```json
"log": "true"
```

Will print the command result in the chat/console/logs when executed.

</details>

<details>

<summary>Chance</summary>

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

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

The command will have 70% chance to be run.

</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 Command Requirement that will spawn a Zombie when the recipe finish with 50% chance:

```json
{
    "type": "custommachinery:command",
    "command": "/summon minecraft:zombie",
    "phase": "ending",
    "permission": 4,
    "chance": 0.5
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.19/recipes/requirements/command.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.
