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.

🔎 FindBlock

Searches for specific blocks within a defined cuboid. Can store all found block IDs and their coordinates in the specified destination.

Syntax

# Basic check for the existence of a block
findblock <from> <to> <block>

# Find and store all matched blocks into a block, entity, or storage
findblock <from> <to> <block> store (block <sourcePos>|entity <source>|storage <source>) [<path>]

Examples

findblock ~5 ~5 ~5 ~-5 ~-5 ~-5 minecraft:barrel[open=true]

Returns 1 if at least one open barrel is found within the area, otherwise 0.

findblock 8 8 8 -8 -8 -8 #minecraft:wool store storage foo:bar found_blocks
  • Returns: The total amount of found wool blocks (e.g., 5).
  • Result: Stores an array of found blocks into the specified storage path.

Note

Data Structure:

[{id:"minecraft:white_wool", x:1, y:2, z:3}, {id:"minecraft:red_wool", x:-1, y:-2, z:-3}]

Clone this wiki locally