Wiki 9Minecraft Wiki 9Minecraft

Using Conditions, Variables, and Loops in Spell Programs

Evaluating Targets with Conditions and Variables

To make smart spells that react to the world around them, store intermediate values using Spell: Set Storage and retrieve them later with Spell: Get Storage. Group mathematical or boolean checks inside Spell: Left Paren and Spell: Right Paren so operations evaluate in the intended order. For example, you can locate a target with Spell: Get Nearest Entity, check its remaining vitality via Spell: Get Entity Health, and compare that value using Spell: Greater Than or Spell: Less Or Equal. Feed the result into Spell: If and close the conditional block with Spell: If Branch End—or flip any boolean check using Spell: Not or Spell: Condition Inverter. You can also inspect terrain ahead of a projectile using Spell: Get Block At Position paired with Spell: Is Air or Spell: Is Gravity Block.

Running Loops and Troubleshooting Spells

For sustained or multi-step spells, wrap repeating actions inside Spell: Loop Start and Spell: Loop End, or set up counted iterations with Spell: For. Insert Spell: Delay inside loops so rapid actions do not execute all on the same tick, and exit early when a condition is met using Spell: Loop Break or skip an iteration with Spell: Loop Continue. Whenever a complex formula behaves unexpectedly, insert Spell: Debug Print to inspect live values during execution.