Run these from an operator’s chat, a command block, or a function file. Stopwatch and Fetchprofile are newer commands — check availability on your Minecraft version.

How to Use the Return Command Generator

  1. Pick a mode: Value returns a fixed integer, Fail reports failure, or Run executes another command and returns its result automatically.
  2. For Value mode, type the integer you want the function to return.
  3. For Run mode, type the command to execute (without the leading slash) – its success/failure and result become the function’s return value.
  4. Copy the generated /return line into a data pack function (.mcfunction file), typically as the last line of that function.

Command Syntax Reference

/return value <value>
/return fail
/return run <command>

/return only works inside a function being run – it immediately stops executing the rest of that function and hands a result back to whatever called it (another function, an execute if function check, or a command block). /return value 1 exits the function early and reports success with a result of 1. /return fail exits and reports failure, which is useful for making an execute if function my_pack:check branch fail on purpose. /return run say hello runs say hello and passes its own success count and result straight through, so the function’s outcome exactly mirrors whatever the wrapped command reports.

Frequently Asked Questions

What’s the difference between /return and just ending the function?

A function that simply reaches its last line without a /return reports success with a result equal to the number of commands that succeeded. /return lets you exit early – skipping any remaining lines – and set an exact, deliberate result value instead of relying on the command count.

Where can I actually use the returned value?

The most common consumer is execute store result score <target> <objective> run function my_pack:my_function, which captures the returned integer into a scoreboard value, or execute if function my_pack:my_function, which branches on whether the function succeeded or failed.

Does /return stop the whole command block chain, not just the function?

No – it only returns from the current function call. If that function was itself invoked by /function from a command block or another function, execution resumes normally in the caller right after the point that called it.

Can I use /return outside a data pack function?

No, running /return directly in chat or the console fails – there’s no function context to return from. It’s exclusively a data pack / .mcfunction command.

Related Tools