
Commander
An extension of the data pack system.
Автор: zenfyr94 тыс.10обновлён 6 авг. 2024 г.
БиблиотекиУтилиты
Описание
Commander
Checkout the wiki to learn more! https://constellation-mc.github.io/commander/
If you have a suggestion or a feature request, be sure to share it here: https://github.com/constellation-mc/commander/discussions/categories/ideas
Quick Introduction
Commander is an extension of the vanilla data pack system.
It adds a new event system:
{
"event": "commander:after_killed_by_other",
"commands": [
]
}
Flexible JSON commands:
{
"type": "commander:commands",
"selector": "commander:random_player",
"commands": [
"/cmd:explode ~ ~1 ~ 2"
]
}
New / commands:
cmd:arithmetica:/cmd:arithmetica "round(346.45, 1)"cmd:explode:/cmd:explode ~ ~ ~ 4
Support for advanced expressions with data access:
minecraft:this_entity.isInWaterOrRain
/say ${{ origin.x }}
There are no client-side features available, everything is done on the server.
Commander is still in beta, so things can change, develop, break.
Modpack creators, DO NOT INCLUDE the .commander folder!
Галерея
Последние версии
Все версии →beta
0.9.0 (1.21)
0.9.0-1.21-build.246 авг. 2024 г.739Minecraft: 1.21, 1.21.1fabric
Что нового
### What's New:
User Changes:
* Added the (data pack) expression library!
This feature allows adding common expressions to a library where each is identified using an Identifier.
```json5
{
"replace": false, // Can be omitted.
"expressions": {
"test:cool_expression": "score * 2.5",
"test:boolean_expression": "level.isDay && !level.isRaining"
}
}
```
Later on, these expressions can be evaluated inside other expressions using the library container, like so:
```
sqrt(library.my_id:some_value) * library.my_id:other_value
```
Or in `execute`/`scoreboard` brigadier commands using `cmd:library`.
Prefer using the library in Brigadier commands!
It does not require parsing the expression in-place!
* Brigadier macros in JSON commands should now correctly fail on dangling braces.
Dev Changes:
* Added more javadoc to the `api` package.
* Removed `evalex` and `mapping-io` from pom.xml
* Added `LongExpression`. Similar to `Arithmetica` and `BooleanExpression`, but for longs!
* Tried to fix expression equality.
* Added missing 'parameter' methods to `Arithmetica`, `BooleanExpression` and `BrigadierMacro`.
* Added `Expression.Result#NULL`.
Other Changes:
* The mod should now fail with slightly better error messages.
* Inlined constant `BooleanExpression` instances.
beta
0.9.0 (1.20.1)
0.9.0-1.20.1-build.236 авг. 2024 г.81,4 тыс.Minecraft: 1.20.1fabric
Что нового
### What's New:
User Changes:
* Added the (data pack) expression library!
This feature allows adding common expressions to a library where each is identified using an Identifier.
```json5
{
"replace": false, // Can be omitted.
"expressions": {
"test:cool_expression": "score * 2.5",
"test:boolean_expression": "level.isDay && !level.isRaining"
}
}
```
Later on, these expressions can be evaluated inside other expressions using the library container, like so:
```
sqrt(library.my_id:some_value) * library.my_id:other_value
```
Or in `execute`/`scoreboard` brigadier commands using `cmd:library`.
Prefer using the library in Brigadier commands!
It does not require parsing the expression in-place!
* Brigadier macros in JSON commands should now correctly fail on dangling braces.
Dev Changes:
* Added more javadoc to the `api` package.
* Removed `evalex` and `mapping-io` from pom.xml
* Added `LongExpression`. Similar to `Arithmetica` and `BooleanExpression`, but for longs!
* Tried to fix expression equality.
* Added missing 'parameter' methods to `Arithmetica`, `BooleanExpression` and `BrigadierMacro`.
* Added `Expression.Result#NULL`.
Other Changes:
* The mod should now fail with slightly better error messages.
* Inlined constant `BooleanExpression` instances.
alpha
0.8.0 (1.21)
0.8.0-1.21-build.2227 июл. 2024 г.184Minecraft: 1.21fabric
Что нового
### What's New:
User Changes:
* Added `?.` and `?` null safe operators.
- `?.` Used on structures. Same as `.`, but returns null if there's no such field in structure.
- `?` Used with anything that can be null. Returns the right operand if left is null or left if not.
These operators allow you to quickly check for nulls in your expressions. Let's image a situation like this:
You have a variable `struct.x` which might not exist and maybe null. Before, you'd have to write something like this:
`if(structContainsKey(struct, 'x') && struct.x != null, struct.x, valueElse())'`
Now this can be shortened to: `struct?.x ? valueElse()`. Do note that `?` has a very low precedence, so in ambiguous cases you'll have to wrap it in parentheses. e.g. `23 + struct?.x ? 23` -> `23 + (struct?.x ? 23)`.
* Java `Optional`s are now unwrapped in expressions.
* Minecraft `Identifier`s are now converted to strings in expressions.
* Gson elements can now be used in expressions.
Dev Changes:
* Fixed `equals` on CustomDataAccessors.
* Added `LootContext` as an argument for the `CustomFields#addVirtualField` function.
Other Changes:
* Updated mEvalEx to fix expression inlining.
beta
0.8.0 (1.20.4)
0.8.0-1.20.4-build.2127 июл. 2024 г.197Minecraft: 1.20.4fabric
Что нового
### What's New:
User Changes:
* Added `?.` and `?` null safe operators.
- `?.` Used on structures. Same as `.`, but returns null if there's no such field in structure.
- `?` Used with anything that can be null. Returns the right operand if left is null or left if not.
These operators allow you to quickly check for nulls in your expressions. Let's image a situation like this:
You have a variable `struct.x` which might not exist and maybe null. Before, you'd have to write something like this:
`if(structContainsKey(struct, 'x') && struct.x != null, struct.x, valueElse())'`
Now this can be shortened to: `struct?.x ? valueElse()`. Do note that `?` has a very low precedence, so in ambiguous cases you'll have to wrap it in parentheses. e.g. `23 + struct?.x ? 23` -> `23 + (struct?.x ? 23)`.
* Java `Optional`s are now unwrapped in expressions.
* Minecraft `Identifier`s are now converted to strings in expressions.
* Gson elements can now be used in expressions.
Dev Changes:
* Fixed `equals` on CustomDataAccessors.
* Added `LootContext` as an argument for the `CustomFields#addVirtualField` function.
Other Changes:
* Updated mEvalEx to fix expression inlining.
beta
0.8.0 (1.20.1)
0.8.0-1.20.1-build.2027 июл. 2024 г.209Minecraft: 1.20.1fabric
Что нового
### What's New:
User Changes:
* Added `?.` and `?` null safe operators.
- `?.` Used on structures. Same as `.`, but returns null if there's no such field in structure.
- `?` Used with anything that can be null. Returns the right operand if left is null or left if not.
These operators allow you to quickly check for nulls in your expressions. Let's image a situation like this:
You have a variable `struct.x` which might not exist and maybe null. Before, you'd have to write something like this:
`if(structContainsKey(struct, 'x') && struct.x != null, struct.x, valueElse())'`
Now this can be shortened to: `struct?.x ? valueElse()`. Do note that `?` has a very low precedence, so in ambiguous cases you'll have to wrap it in parentheses. e.g. `23 + struct?.x ? 23` -> `23 + (struct?.x ? 23)`.
* Java `Optional`s are now unwrapped in expressions.
* Minecraft `Identifier`s are now converted to strings in expressions.
* Gson elements can now be used in expressions.
Dev Changes:
* Fixed `equals` on CustomDataAccessors.
* Added `LootContext` as an argument for the `CustomFields#addVirtualField` function.
Other Changes:
* Updated mEvalEx to fix expression inlining.
alpha
0.7.0 (1.21)
0.7.0-1.21-build.1925 июл. 2024 г.186Minecraft: 1.21fabric
Что нового
### What's New:
User Changes:
* Added `arrayFindAny` and `arrayFindFirst` functions to expressions. As the name suggests, those functions will try to find an element of an array or return `null` if the array is empty.
* Added `chain` function to expressions. This function operates on the results of the first one and allows chaining multiple function calls together like so:
```
//`it` is the result of the previous function, unless there's a lower level lamda.
chain(arrayOf(2, 3, 6), arrayMap(it, sqrt(it)), arrayFindFirst(it));
//this is the same as:
arrayFindFirst(arrayMap(arrayOf(2, 3, 6), sqrt(it)))
```
* Added `remove` to `cmd:data`.
* Added `cmd:operate` to the `scoreboard players` command.
* Added registry access for expressions! Now you can access the game's static and dynamic content registries by using new `Registry` and `DynamicRegistry` functions.
* Why is this useful? For example, this allows you to compare item stacks based on their item type:
```
this_entity.getHandSlots[0].getItem == Registry('item').access.chest
```
* For item and block registries there is a shortcut: `Item`, `Block`.
```
this_entity.getHandSlots[0].getItem == Item('chest')
```
* `Biome` and `DimensionType` are available dynamic registry shortcuts.
Dev Changes:
There's a handful new experimental APIs, which allow you to extend the expression system.
* Exposed `Object getValue()` and `Result convert(Object o)` in Expression.Result.
* Exposed `Expression eval(LootContext context, Map<String, Object> parameters)` in Expression.
* Exposed `ProxyMap`, `ObjectConverter` and `CustomDataAccessor` (which is now a valid data type).
* Exposed `CustomFields`. One of the more interesting APIs. Allows adding new 'virtual' fields to reflective expression objects.
```java
static {
CustomFields.addVirtualField(Entity.class, "nbt", NbtPredicate::entityToNbt);
}
```
Other Changes:
* Switched to a custom fork of EvalEx.
* Switched to 16-digit precision from the EvalEx's standard of 68-digit.
beta
0.7.0 (1.20.4)
0.7.0-1.20.4-build.1825 июл. 2024 г.222Minecraft: 1.20.4fabric
Что нового
### What's New:
User Changes:
* Added `arrayFindAny` and `arrayFindFirst` functions to expressions. As the name suggests, those functions will try to find an element of an array or return `null` if the array is empty.
* Added `chain` function to expressions. This function operates on the results of the first one and allows chaining multiple function calls together like so:
```
//`it` is the result of the previous function, unless there's a lower level lamda.
chain(arrayOf(2, 3, 6), arrayMap(it, sqrt(it)), arrayFindFirst(it));
//this is the same as:
arrayFindFirst(arrayMap(arrayOf(2, 3, 6), sqrt(it)))
```
* Added `remove` to `cmd:data`.
* Added `cmd:operate` to the `scoreboard players` command.
* Added registry access for expressions! Now you can access the game's static and dynamic content registries by using new `Registry` and `DynamicRegistry` functions.
* Why is this useful? For example, this allows you to compare item stacks based on their item type:
```
this_entity.getHandSlots[0].getItem == Registry('item').access.chest
```
* For item and block registries there is a shortcut: `Item`, `Block`.
```
this_entity.getHandSlots[0].getItem == Item('chest')
```
* `Biome` and `DimensionType` are available dynamic registry shortcuts.
Dev Changes:
There's a handful new experimental APIs, which allow you to extend the expression system.
* Exposed `Object getValue()` and `Result convert(Object o)` in Expression.Result.
* Exposed `Expression eval(LootContext context, Map<String, Object> parameters)` in Expression.
* Exposed `ProxyMap`, `ObjectConverter` and `CustomDataAccessor` (which is now a valid data type).
* Exposed `CustomFields`. One of the more interesting APIs. Allows adding new 'virtual' fields to reflective expression objects.
```java
static {
CustomFields.addVirtualField(Entity.class, "nbt", NbtPredicate::entityToNbt);
}
```
Other Changes:
* Switched to a custom fork of EvalEx.
* Switched to 16-digit precision from the EvalEx's standard of 68-digit.
beta
0.7.0 (1.20.1)
0.7.0-1.20.1-build.1725 июл. 2024 г.313Minecraft: 1.20.1fabric
Что нового
### What's New:
User Changes:
* Added `arrayFindAny` and `arrayFindFirst` functions to expressions. As the name suggests, those functions will try to find an element of an array or return `null` if the array is empty.
* Added `chain` function to expressions. This function operates on the results of the first one and allows chaining multiple function calls together like so:
```
//`it` is the result of the previous function, unless there's a lower level lamda.
chain(arrayOf(2, 3, 6), arrayMap(it, sqrt(it)), arrayFindFirst(it));
//this is the same as:
arrayFindFirst(arrayMap(arrayOf(2, 3, 6), sqrt(it)))
```
* Added `remove` to `cmd:data`.
* Added `cmd:operate` to the `scoreboard players` command.
* Added registry access for expressions! Now you can access the game's static and dynamic content registries by using new `Registry` and `DynamicRegistry` functions.
* Why is this useful? For example, this allows you to compare item stacks based on their item type:
```
this_entity.getHandSlots[0].getItem == Registry('item').access.chest
```
* For item and block registries there is a shortcut: `Item`, `Block`.
```
this_entity.getHandSlots[0].getItem == Item('chest')
```
* `Biome` and `DimensionType` are available dynamic registry shortcuts.
Dev Changes:
There's a handful new experimental APIs, which allow you to extend the expression system.
* Exposed `Object getValue()` and `Result convert(Object o)` in Expression.Result.
* Exposed `Expression eval(LootContext context, Map<String, Object> parameters)` in Expression.
* Exposed `ProxyMap`, `ObjectConverter` and `CustomDataAccessor` (which is now a valid data type).
* Exposed `CustomFields`. One of the more interesting APIs. Allows adding new 'virtual' fields to reflective expression objects.
```java
static {
CustomFields.addVirtualField(Entity.class, "nbt", NbtPredicate::entityToNbt);
}
```
Other Changes:
* Switched to a custom fork of EvalEx.
* Switched to 16-digit precision from the EvalEx's standard of 68-digit.
beta
0.6.0 (1.20.4)
0.6.0-1.20.4-build.1611 июл. 2024 г.151Minecraft: 1.20.4fabric
Что нового
### What's New:
User Changes:
* Added `cmd:expression` to `/execute if`.
* Updated EvalEx to v3.3.0. [Release Notes...](https://github.com/ezylang/EvalEx/releases/tag/3.3.0)
* Removed `commander:store_expression_data` and `commander:store_nbt_data` JSON commands, as they can be easily replaced by the brigadier command and don't offer any advantages.
Example replacement:
```json
{
"type": "commander:store_expression_data",
"target": "level",
"selector": "origin",
"key": "my_cool_data",
"expression": "random(0, 2)"
}
```
Becomes:
```json
{
"type": "commander:commands",
"selector": "origin",
"commands": [
"cmd:data write level my_cool_data ${{random(0, 2)}}"
]
}
```
beta
0.6.0 (1.20.1)
0.6.0-1.20.1-build.1511 июл. 2024 г.1,3 тыс.Minecraft: 1.20.1fabric
Что нового
### What's New:
User Changes:
* Added `cmd:expression` to `/execute if`.
* Updated EvalEx to v3.3.0. [Release Notes...](https://github.com/ezylang/EvalEx/releases/tag/3.3.0)
* Removed `commander:store_expression_data` and `commander:store_nbt_data` JSON commands, as they can be easily replaced by the brigadier command and don't offer any advantages.
Example replacement:
```json
{
"type": "commander:store_expression_data",
"target": "level",
"selector": "origin",
"key": "my_cool_data",
"expression": "random(0, 2)"
}
```
Becomes:
```json
{
"type": "commander:commands",
"selector": "origin",
"commands": [
"cmd:data write level my_cool_data ${{random(0, 2)}}"
]
}
```
