-
Notifications
You must be signed in to change notification settings - Fork 0
Commands
Жаба edited this page Jul 7, 2026
·
3 revisions
Evaluates mathematical and logical expressions represented as a string and returns its completion value. Supports variables via arguments and with macros.
# Basic Math
eval <expression> [<scale>]
# Evaluation with inline arguments
eval <expression> [<scale>] <arguments>
# Evaluation with arguments passed from data storage, entity, or block
eval <expression> [<scale>] with (block <sourcePos>|entity <source>|storage <source>) [<path>]-
<expression>: A string representing the mathematical or logical expression. -
[<scale>]: (Optional) An integer multiplier for the return value (defaults to 1). Useful because Minecraft commands only return integers.
eval "2.5 + 2.5" 1Returns 5.
eval "sqrt(x^y) + y" 1 {x:10, y:2}Returns 12.
execute unless data storage foo:bar for_loop.i run data modify storage foo:bar i set value 0
execute store result storage foo:bar for_loop.i int 1 run eval "i + 1" 1 with storage foo:bar for_loopIncreases i on every iteration and returns it.
execute store result storage foo:bar const.PI2 double 0.1 run eval "deg(PI) * 2" 10Returns 3600
Note
How it works: deg(PI) * 2 equals 360.0. The scale 10 multiplies it, making the command return 3600. Finally, double 0.1 multiplies it by 0.1 before saving, resulting in exactly 360.0d inside your storage.