Skip to content

Variables

Blast edited this page Jul 22, 2026 · 1 revision

Macro Variables

Macro variables let a command use information from the game when it runs.

For example:

/say I am looking at %targetEntity.getName().getString()%

Variables must be surrounded by % symbols.

Available Variables

targetEntity

The entity you are currently looking directly at.

%targetEntity.getUUID()%

This will not resolve when you are not looking at an entity.

nearestEntity

The nearest living, non-spectator entity within 10 blocks.

%nearestEntity.getName().getString()%

minecraft

The current Minecraft client.

%minecraft.player.getUUID()%

This is intended for more advanced variables.

Fields and Methods

Variables access Minecraft's actual mapped fields and methods.

A field does not use parentheses:

%minecraft.player%

A method uses parentheses:

%targetEntity.getUUID()%

Methods can be chained together:

%targetEntity.getName().getString()%

Names must match exactly and are case-sensitive. The resolver will not correct spelling or search for a similar name.

getUUID()

is different from:

getUuid()

Minecraft Mappings

These variables do not use a custom list of simplified names. They directly use the mapped names from Minecraft's game code.

This means basic variables can be copied from examples in this wiki, while advanced users can access other mapped Minecraft fields and methods.

For example:

%minecraft.player.getUUID()%

accesses the Minecraft client's player field and then calls the player's getUUID() method.

Because these names come from Minecraft itself, some advanced variables may change or stop working after updating to a different Minecraft version.

Method Parameters

Methods can accept the following values:

null
5
2.5
"some text"
true
false

Example:

%targetEntity.someMethod(5, 2.5, "Hello", true, null)%

Strings must use double quotes.

Variables as Parameters

A variable can be passed into another method:

%targetEntity.distanceToSqr(%nearestEntity%)%

The nested variable must include its own % symbols.

Multiple Variables

A command may contain multiple variables:

/tp %nearestEntity.getUUID()% %targetEntity.getUUID()%

Each variable is resolved separately.

Failed Variables

If a variable cannot be resolved, it is left unchanged.

For example, when no entity is being targeted:

/say %targetEntity.getUUID()%

will remain unchanged.

A variable may fail when:

  • The entity or value is unavailable.
  • The field or method does not exist.
  • The capitalization is incorrect.
  • The method parameters do not match.
  • The mapped name changed between Minecraft versions.

Examples

Targeted entity's name:

%targetEntity.getName().getString()%

Nearest entity's UUID:

%nearestEntity.getUUID()%

Your UUID:

%minecraft.player.getUUID()%

Distance between two entities:

%targetEntity.distanceToSqr(%nearestEntity%)%