DatapackJava
/return
Stops the current function immediately and sets its return value, which the calling /execute or /function can capture. /return run lets you return the result of another command. Added in 1.20 — brings early-exit and value-returning control flow to datapack functions.
What is /return used for?
Syntax
Parameters
- value
- integer
- Value to return from the function.
- commandoptional
- command
- Run a command and return its result (for run).
Examples
Exit the function now, returning 1 (success).
Return the executor's health value.
Permission level
/return requires Cheats (op level 2). In single-player you need the world's "Allow Cheats" toggle on. On a multiplayer server you need to be opped — see /op.