Skip to content

Commands

Жаба edited this page Jul 7, 2026 · 3 revisions

🧮 Eval

Evaluates mathematical and logical expressions represented as a string and returns its completion value. Supports variables via arguments and with macros.

Syntax

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

Examples

Basic Math

eval "2.5 + 2.5" 1

Returns 5.

Using Inline Arguments

eval "sqrt(x^y) + y" 1 {x:10, y:2}

Returns 12.

Using Source Arguments

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_loop

Increases i on every iteration and returns it.

Advanced Math with Scaling

execute store result storage foo:bar const.PI2 double 0.1 run eval "deg(PI) * 2" 10

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

Clone this wiki locally