-
Notifications
You must be signed in to change notification settings - Fork 0
Commands
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.
Searches for specific blocks within a defined cuboid. Can store all found block IDs and their coordinates in the specified destination.
# 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>]-
<from>: block_pos and<to>: block_pos -
<block>: block_state
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}]
Allows various manipulations with virtual menus.
# Open menu
gui open <target> <menu> [<name>] [<force>]
# Close any menu
gui close <target>
# Close specific menu
gui close <target> [<menu>]-
<target>- Player -
<menu>- Menu type -
[<name>]- Menu name (Text Component) -
[<force>]- Will the menu open on top of another one? (Closing already opened)
gui open @s minecraft:generic_9x3 "Example Menu"Open basic menu with name as plain string.
gui open @s minecraft:generic_9x3 {text:"Cool Menu",color:"blue",italic:true} falseOpen menu with name as text component.
# Open menu
gui open @s minecraft:generic_9x1 {text:"Gift"} false
# Set contents
data modify entity @s "fabric:attachments"."tophat:virtual_items" set value [{Slot:3b,id:"minecraft:diamond",count:1},{Slot:4b,id:"minecraft:cookie",count:1},{Slot:5b,id:"minecraft:diamond",count:1}]Open menu with already existing content
Note
You can access and modify contents of the virtual menu from player's data "fabric:attachments"."tophat:virtual_items"