User Changes:
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!
Dev Changes:
api package.evalex and mapping-io from pom.xmlLongExpression. Similar to Arithmetica and BooleanExpression, but for longs!Arithmetica, BooleanExpression and BrigadierMacro.Expression.Result#NULL.Other Changes:
BooleanExpression instances.User Changes:
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!
Dev Changes:
api package.evalex and mapping-io from pom.xmlLongExpression. Similar to Arithmetica and BooleanExpression, but for longs!Arithmetica, BooleanExpression and BrigadierMacro.Expression.Result#NULL.Other Changes:
BooleanExpression instances.User Changes:
?. 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).
Optionals are now unwrapped in expressions.Identifiers are now converted to strings in expressions.Dev Changes:
equals on CustomDataAccessors.LootContext as an argument for the CustomFields#addVirtualField function.Other Changes:
User Changes:
?. 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).
Optionals are now unwrapped in expressions.Identifiers are now converted to strings in expressions.Dev Changes:
equals on CustomDataAccessors.LootContext as an argument for the CustomFields#addVirtualField function.Other Changes:
User Changes:
?. 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).
Optionals are now unwrapped in expressions.Identifiers are now converted to strings in expressions.Dev Changes:
equals on CustomDataAccessors.LootContext as an argument for the CustomFields#addVirtualField function.Other Changes:
