Conditions, loops, and flow control
If and Else
Section titled “If and Else”Place If, select its condition, and configure its typed inputs. Its nested body runs when true. Choose Else through Control → Flow → Else for the opposite branch. If can also invoke a method that returns Boolean.
Conditions include numeric comparisons, String tests, entity/player state, lists, dictionaries, items, and plot/world checks. Pick the appropriate target first. Boolean-returning conditions do not need a Number or String result Variable.
Choose Control → Flow → Loops. Available families include:
- Repeat Multiple Times: run the body for a count.
- Repeat For Each in List: assign each element to a compatible Current Value Variable.
- Repeat On Grid: iterate locations between corners into a Location Variable.
- Repeat While: re-evaluate the chosen comparison/test before repeating.
Configure loop body structure in the editor, not by placing unrelated blocks nearby. Use matching element types for list iteration and keep grid corners inside the plot. Large loops consume execution budgets; use bounded work and Wait where appropriate.
Control operations
Section titled “Control operations”Wait suspends the current task. Its duration is in ticks; Minecraft normally targets 20 ticks per second. Waiting does not block the server thread. Stop Repeat exits the current loop; Skip Iteration advances to the next iteration. Return From Function returns from a method; End Thread ends the current task/line.
A non-Void method needs a compatible return value and a return on every reachable completion path. Returning from an inner loop is different from merely breaking that loop.
Event cancellation
Section titled “Event cancellation”Use Cancel Event or Uncancel Event while the event is still synchronous. After Wait or suspension, its original mutation window is gone. Event snapshots may remain readable, but they do not let you change the already-processed event.
Worked layout
Section titled “Worked layout”Event: Player Right Click If: Number > Variable: Private Number score Compare With: 0 Body: Call Method → Event Target → Send Message Message: Your score is ${private.score} Else Call Method → Event Target → Send Message Message: Score a point first.Assign score within the same event before reading it; use Public or Save instead if it must survive across event calls. See exceptions for Try/Catch/Finally and cleanup during returns or loop exits.