Minecraft Wiki

The Minecraft Wiki has moved from Fandom; see the linked discussion page for details.

READ MORE

Minecraft Wiki
Advertisement
Information icon
This feature is exclusive to Java Edition. 

A command that can be embedded inside a function to control the execution of the function. Terminate the execution of the function and set the return value of the invoked function to an arbitrary integer value. By setting the return value to an arbitrary value, it can be used to record the execution results of /function commands with conditional branches and reflect them in subsequent function executions.

Usage

By placing this command at the end of a function , especially a function with a conditional branch. You can terminate the function and record which branch the function followed as a return value. The return value can be recorded using The recorded return value can be referenced. And can be reflected in the execution of other commands and functions.

Syntax

/return <value> Terminate the function to which it belongs and /function set the return value of the command to an arbitrary integer value.

/return run <command>[upcoming: JE 1.20.2] Executes the command specified in , terminates the function /function to which it belongs, and uses the return value of that command as the return value of the command that executed that function. If the executed command fails, the return value will be 0.

Arguments

引数

<Value> An integer value to set to the return value of the command that invoked the function to which this command belongs. Function specify with a 32-bit integer value. Also, specify a value between -2,147,483,648 and 2,147,483,647.

<Command> A command that gives the return value of the command that invoked the function to which this command belongs.

Result

CommandTriggerJava Edition
anyIncorrectly Specified Arguments Unparseable
return <value>valueis outside the allowed range (-2147483648 to 2147483647) or is not an intege Failed
return run <command><command>command in fails Failed
anyOtherwiseStops execution of the function to which it belongs and gives the specified return value /function to

Output

Originally /function a command that gives a return value to /return <value> but also the return value of the command itself . /return run ... There is no return value for either command itself.

CommandEditionSituationSuccess Count/execute store success .../execute store result ...
return <value>Java Editionwhen successful11Return valueThe value of the.

History

Java Edition
1.2023w16aAdded return.
1.20.223w31aAdded a new subcommand run to return.
Advertisement