Mods
Resource Packs
Data Packs
Modpacks
Shaders
Plugins
Mods Resource Packs Data Packs Plugins Shaders Modpacks
Get Modrinth App Upgrade to Modrinth+
Sign in
ModsPluginsData PacksShadersResource PacksModpacks
Sign in
Settings
Commander

Commander

An extension of the data pack system.

42.3k
13
Library
Utility

Compatibility

Minecraft: Java Edition

1.21.x
1.20.4
1.20.1

Platforms

Fabric

Supported environments

Server-side

90% of ad revenue goes to creators

Support creators and Modrinth ad-free with Modrinth+

Links

Report issues View source Visit wiki

Creators

constellation
constellationOrganization

melontini
melontini Author

Details

Licensed MIT
Published last year
Updated 10 months ago
DescriptionGalleryChangelogVersions

Show all versions

1
2

0.9.0 (1.21)

by melontini on Aug 6, 2024
Download

0.9.0 (1.20.1)

by melontini on Aug 6, 2024
Download

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.

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

0.8.0 (1.21)

by melontini on Jul 27, 2024
Download

0.8.0 (1.20.4)

by melontini on Jul 27, 2024
Download

0.8.0 (1.20.1)

by melontini on Jul 27, 2024
Download

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 Optionals are now unwrapped in expressions.
  • Minecraft Identifiers 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.

0.7.0 (1.21)

by melontini on Jul 25, 2024
Download

0.7.0 (1.20.4)

by melontini on Jul 25, 2024
Download

0.7.0 (1.20.1)

by melontini on Jul 25, 2024
Download

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

0.6.0 (1.20.4)

by melontini on Jul 11, 2024
Download

0.6.0 (1.20.1)

by melontini on Jul 11, 2024
Download

What's New:

User Changes:

  • Added cmd:expression to /execute if.
  • Updated EvalEx to v3.3.0. Release Notes...
  • 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:

{
  "type": "commander:store_expression_data",
  "target": "level",
  "selector": "origin",
  "key": "my_cool_data",
  "expression": "random(0, 2)"
}

Becomes:

{
  "type": "commander:commands",
  "selector": "origin",
  "commands": [
    "cmd:data write level my_cool_data ${{random(0, 2)}}"
  ]
}

0.5.0 (1.20.4)

by melontini on May 11, 2024
Download

0.5.0 (1.20.1)

by melontini on May 11, 2024
Download

What's New:

User Changes:

This update introduces new JSON commands to interact with persistent data.

commander:store_nbt_data which allows you to store a simple string or number value, and commander:store_expression_data just like store_nbt_data, but with expressions.

{
  "type": "commander:store_nbt_data", //command type
  "target": "level", //the target we want to attach data to.
  "selector": "origin", //Selector for position and entity targets.
  "key": "cmd_my_cool_data", //The data key for later reference.
  "element": "Hello World!" //Our string or number value. This is a nbt element, so true and false are not supported.
}

store_expression_data is identical, but element is renamed to expression and only accepts expressions.

The target can be one of the following:

  • level current level. Any selector.
  • chunk selected chunk. Position selector.
  • entity selected entity. Entity selector.
  • block_entity selected block entity. Position selector.

Later on this data can be used in expressions like so:

level.storage.my_cool_data * 0.7 or this_entity.storage.even_cooler_data == 'freak''.

Along with the JSON command this update introduces a the cmd:data brigadier command. This command allows you to read and write data just like the JSON command.

The syntax goes like this:

cmd:data -> operation (read/write) -> target -> selector (@s/~ ~ ~) -> key (-> data (for write))

Other Changes:

  • Moved mappings cache to ~/.commander.
  • Mapping are now saved as compressed TSRG2.

Dev Changes:

  • Added is(Type)Value to expression result.

0.4.1 (1.20.4)

by melontini on May 10, 2024
Download

0.4.1 (1.20.1)

by melontini on May 10, 2024
Download

What's New:

User Changes:

  • Fixed arrayAllMatch acting like arrayAnyMatch.
  • Added attributes field to living entities.
  • Loot Context access in expressions is now cached.

0.4.0 (1.20.4)

by melontini on May 9, 2024
Download

0.4.0 (1.20.1)

by melontini on May 9, 2024
Download

What's New:

User Changes:

This update extends the expression syntax to support nbt and block properties.

  • Returned to downloading mappings at startup.
  • Compound and List NBT tags are now properly supported.
  • Added nbt field to item stacks, entities and block entities.

This Allows you to access NBT data like so: this_entity.nbt.Air. You should avoid NBT access, as it can get extremely slow.

  • Added properties field to *states.

This can be used to access block state properties like so: block_state.properties.candles.

  • Added lots of new functions. Consult the wiki for more info!
  • Added short_circuit to defaulted, all_of, any_of. If true, commands will terminate immediately upon the condition failing.
  • hasContext and structContainsKey now accept VarArgs.
  • Removed arbitrary map support, as it was pretty poorly implemented.
  • Constants are now case-sensitive.

Dev Changes:

  • Moved Command codecs to MapCodec.
  • Added BooleanExpression, similar to Arithmtica.
  • Added runTriState to EventExecutors.

0.3.2 (1.20.4)

by melontini on Apr 27, 2024
Download

0.3.2 (1.20.1)

by melontini on Apr 27, 2024
Download

What's New:

  • Slightly improved error messages returned by cmd:arithmetica.

0.3.1 (1.20.1)

by melontini on Apr 26, 2024
Download

0.3.1 (1.20.4)

by melontini on Apr 26, 2024
Download

What's New:

  • Added hasContext function to expressions. Allows checking if loot context has the required parameter: if(hasContext("tool"), "Hi", "Bye")
1
2

Modrinth is open source.

main@396f737

© Rinth, Inc.

Company

TermsPrivacyRulesCareers

Resources

SupportBlogDocsStatus

Interact

Discord X (Twitter) Mastodon Crowdin
Get Modrinth App Settings
NOT AN OFFICIAL MINECRAFT SERVICE. NOT APPROVED BY OR ASSOCIATED WITH MOJANG OR MICROSOFT.