diff --git a/docs/.vitepress/en.ts b/docs/.vitepress/en.ts index 9ce4038..377c17f 100644 --- a/docs/.vitepress/en.ts +++ b/docs/.vitepress/en.ts @@ -18,6 +18,7 @@ export const en = defineConfig({ { text: 'Events', link: '/Events' }, { text: 'Commands', link: '/Commands' }, { text: 'Expressions', link: '/Expressions' }, + { text: 'Brigadier Commands', link: '/BrigadierCommands' }, ] }, { diff --git a/docs/BrigadierCommands.md b/docs/BrigadierCommands.md new file mode 100644 index 0000000..7c7a9c3 --- /dev/null +++ b/docs/BrigadierCommands.md @@ -0,0 +1,74 @@ +# Brigadier Commands + +Commander introduces a handful of `/` commands. All commands require perm level 2. + +## `cmd:arithmetica` + +This command allows you evaluate expressions right in the chat. Context: `minecraft:level`, `minecraft:origin` and optional `minecraft:this_entity`. This command requires a string expression and an optional cast. + +``` +cmd:arithmetica -> + \- expression + \- cast (default: none) +``` + +Example: `cmd:arithmetica "sin(level.getDayTime)" bool` + +## `cmd:explode` + +This simple command allows you to spawn explosions. The command tree is as follows: + +``` +cmd:explode -> + \- entity (who caused the explosion) + \- position + \- [power] (default: 4) + \- [fire] (default: false) + \- position + \- [power] (default: 4) + \- [fire] (default: false) +``` + +Example: `cmd:explode @s ~ ~ ~ 6.4 true` + +## `cmd:data` + +This command allows you to read and write special, persistent data which can later be referenced in expressions. Provided data must be either a number or a string. The command tree is as follows: + +::: details Tree +``` +cmd:data + \- read + \- level + \- key + \- chunk + \- position + \- key + \- entity + \- entity + \- key + \- block_entity + \- position + \- key + \- write + \- level + \- key + \- data + \- chunk + \- position + \- key + \- data + \- entity + \- entity + \- key + \- data + \- block_entity + \- position + \- key + \- data +``` +::: + +Example: `cmd:data read entity @s "my_test_data"` or `cmd:data write entity @s "my_test_data" "Hello "` + +Example reference: `this_entity.storage.my_test_data + 'World!'` \ No newline at end of file diff --git a/docs/Commands.md b/docs/Commands.md index 9429343..0f6f26c 100644 --- a/docs/Commands.md +++ b/docs/Commands.md @@ -150,4 +150,44 @@ This command type takes a weighted list of other commands and randomly executes ] } ``` +::: + +### `commander:store_expression_data` and `commander:store_nbt_data` + +These commands allows you to write data to a Commander data storage. This is a JSON variant of the [`/cmd:data`](/BrigadierCommands#cmd-data) command. + +Both commands require the following arguments: + +| Argument | Description | +|---|---| +| `target` | The target that you want to write data to. Can be `level`, `chunk`, `entity`, `block_entity`. | +| `selector` | A regular selector which selects the target of specified type. | +| `key` | The identifying key of the data you want to store | + +The `nbt` command requires a static number or a string. (`element` field) + +The `expression` command requires an expression which returns a number or a string. (`expression` field) + +::: details Example +```json +{ + "type": "commander:store_expression_data", + "target": "level", + "selector": "origin", + "key": "cmd_my_cool_data", + "expression": "random(0, 2)" +} +``` + +
+ +```json +{ + "type": "commander:store_nbt_data", + "target": "entity", + "selector": "this_entity", + "key": "cmd_my_cool_data", + "element": 45 +} +``` ::: \ No newline at end of file diff --git a/docs/Expressions.md b/docs/Expressions.md index 3469906..1642dab 100644 --- a/docs/Expressions.md +++ b/docs/Expressions.md @@ -90,6 +90,20 @@ Example: `block_state.properties.candles` ::: +::: details `attributes` (Living Entities) + +Allows you to access entity attributes. The key is an identifier, so both `generic.luck` and `minecraft:generic.luck` are acceptible. + +Example: `this_entity.attributes.'generic.luck'` + +::: + +::: details `storage` (Levels, Chunks, Entities, Block Entities) + +Allows you to access persistent data storage. The data is modified and written by [`/cmd:data`](/BrigadierCommands#cmd-data), [`commander:store_nbt_data`](/Commands#commander-store-expression-data-and-commander-store-nbt-data) or [`commander:store_expression_data`](/Commands#commander-store-expression-data-and-commander-store-nbt-data) + +::: + ### P.S. If you have to do a lot of expensive operations in expressions in tick events, you should delay the execution, if possible, by checking `level.getDayTime % 20 == 0`, this will make sure that the expression is executed every second and not 20 times per second. `% 40` is every 2 seconds and `% 10` is every 1/2 second.