angle-rightVariable System

What Are Variables?

Variables are dynamic values that change based on the situation. They let you:

  • Scale effects with enchant level

  • React to damage dealt

  • Use random values consistently

  • Reference positions and entities

  • Perform calculations


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:

  • Damage/amount fields

  • Text/messages

  • Math expressions

  • Position offsets


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:

  • Hit location (HIT_MOB)

  • Death location (MOB_DEATH)

  • Player location (PASSIVE)

{trigger_x}, {trigger_y}, {trigger_z} - Trigger coordinates


Loop Variables

{iteration} - Current loop iteration (loops only)

The iteration variable starts at 0:

  • First loop: {iteration} = 0

  • Second loop: {iteration} = 1

  • Third loop: {iteration} = 2

  • etc.


Custom Variables

Create your own variables with the set-variable action:

Basic Usage

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:

Operators

  • + Addition

  • - Subtraction

  • * Multiplication

  • / Division

  • () Parentheses

Examples

Simple scaling:

Add base + scaling:

Percentage of damage:

Complex formula:

Amplifier calculation:

Conditional math:


Placeholder Support

You can use PlaceholderAPI placeholders as variables.

Random Numbers

Generates random number between 50-200 each time.

Format Numbers

Formats large numbers (1500 → 1.5k, 1000000 → 1M)

Player Stats

Give 1% of player's current money.

Combining

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

1

Check spelling

Ensure the variable name matches exactly where it's set and where it's used.

2

Ensure it's set before use

Variables must be created with set-variable (or be built-in) before being referenced.

Wrong Value

Problem: Variable has unexpected value

1

Debug hologram

Add a hologram to display the value:

2

Check math expression syntax

Look for misplaced operators or parentheses.

3

Verify placeholder resolution

If using placeholders, confirm they resolve as expected.

Math Not Calculating

Problem: {level} * 100 shows as text, not calculated

1

Field support

Ensure the field supports expressions (damage, amount, etc.).

2

Check for syntax errors

Confirm there are no stray quotes or invalid characters.

3

Use set-variable for complex math

Then reference {result} where needed.


Last updated