What Are Variables?
Variables are dynamic values that change based on the situation. They let you:
Scale effects with enchant level
Use random values consistently
Reference positions and entities
Using Variables
Variables are written with curly braces: {variable_name}
# Use in damage
damage: "{level} * 50"
# Use in text
text: "&c+{damage} Damage!"
# Use in calculations
amount: "100 + {level} * 10"
Variables work in:
Built-in Variables
These variables are automatically available in every action:
Player Variables
{player} - Player's name
{player_pos} - Player's current location
{player_x}, {player_y}, {player_z} - Player's coordinates
{player_yaw} - Player's horizontal rotation (0-360)
{player_pitch} - Player's vertical rotation (-90 to 90)
Enchant Variables
{level} - Current enchant level
Combat Variables
{damage} - Damage dealt (HIT_MOB trigger only)
{target_mob} - Target mob's entity ID
{target_pos} - Target mob's location
{target_x}, {target_y}, {target_z} - Target coordinates
Trigger Variables
{trigger_pos} - Where the enchant was activated
This could be:
Death location (MOB_DEATH)
Player location (PASSIVE)
{trigger_x}, {trigger_y}, {trigger_z} - Trigger coordinates
{iteration} - Current loop iteration (loops only)
The iteration variable starts at 0:
First loop: {iteration} = 0
Second loop: {iteration} = 1
Third loop: {iteration} = 2
Custom Variables
Create your own variables with the set-variable action:
Why Use Custom Variables?
Problem: You want to show the same random value in multiple places.
The hologram will show a different random number than what was given/
Entity References
Store entity IDs for later use:
Math Expressions
Variables support mathematical operations:
Simple scaling:
Add base + scaling:
Percentage of damage:
Complex formula:
Amplifier calculation:
Conditional math:
Placeholder Support
You can use PlaceholderAPI placeholders as variables.
Generates random number between 50-200 each time.
Formats large numbers (1500 → 1.5k, 1000000 → 1M)
Give 1% of player's current money.
Mix variables and placeholders:
Position Variables
Variables work in positions too:
Basic Position Variables
Math in Positions
Add offsets:
With variables:
Entity Positions
Reference spawned entities:
Troubleshooting
Variable Not Resolving
Problem: Variable shows as {my_var} instead of value
Ensure the variable name matches exactly where it's set and where it's used.
Ensure it's set before use
Variables must be created with set-variable (or be built-in) before being referenced.
Problem: Variable has unexpected value
Add a hologram to display the value:
Check math expression syntax
Look for misplaced operators or parentheses.
Verify placeholder resolution
If using placeholders, confirm they resolve as expected.
Math Not Calculating
Problem: {level} * 100 shows as text, not calculated
Ensure the field supports expressions (damage, amount, etc.).
Check for syntax errors
Confirm there are no stray quotes or invalid characters.
Use set-variable for complex math
Then reference {result} where needed.