News
Game
Guides
Downloads
Versions
/return
COMMANDS COMMAND BLOCKS & MAPS CHEATS · LEVEL 2 Added in 1.20

/return command in Minecraft

/return stops the current function and hands a value back to the command that called it. /return fail makes the call fail instead, and /return run returns the result of another command. It turns functions into reusable checks for /execute if function and /execute store.

Syntax

/return fail
/return run …
/return <value>
ArgumentExpectsWhat it does
valueWhole numberWhole number handed back to the caller; execute if function treats 0 as a failed test.

Examples

Return a value

/return 1

Ends the function at once and returns 1. Write it in a .mcfunction file without the slash.

Java 26.3

Make the function fail

/return fail

Ends the function as failed: execute if function does not pass and store success stores 0.

Java 26.3

Stop early with a check

/execute unless entity @s[tag=ready] run return 0

Placed at the top of a function, ends it for any executor without the ready tag.

Java 26.3

Use a function as a test

/execute if function mypack:has_key run say Door unlocked

Runs mypack:has_key and posts the message only if it returns a value other than 0.

Java 26.3

Store a returned value

/execute store result score total calc run function mypack:count_mobs

Writes the number returned by mypack:count_mobs into the invented holder total of the calc objective.

Java 26.3
Build your command

Fill in the fields, then copy the command.

Command generator

Return values in practice

Inside a function, return 1 ends the file at once: the lines below it never run. The value goes to whatever called the function. Typed in chat, /function answers "Function ... returned 1". execute if function passes when the value is not 0, and execute store result writes it into a /scoreboard score.

return fail ends the function as a failure, so execute if function fails and store success stores 0. return run runs one command and returns its result, for example return run scoreboard players get @s coins to hand back a score.

Patterns

  • Early exit: execute unless entity @s[tag=ready] run return 0 at the top of a function skips the rest for entities without the tag.
  • Reusable checks: a function that returns 1 or 0 can be tested with /execute from any other function or command block.
  • Guard clauses keep tick functions cheap: stop as soon as there is nothing to do.

✓ Checked in Java Edition 26.3 · updated 2 November 2026

/return: FAQ

Can /return give back a decimal number?

No, the value is a whole number. Multiply the value first, for example by 100, if you need decimals.

What happens to the commands after /return?

They are skipped. The function stops on the /return line, so place it where the work is done or where a check fails.

How do I use /return?

Type it in the chat with cheats on: /return fail.

Who can use /return?

Cheats on, or operator level 2.

Since when does /return exist?

It is in the official command tree since Java Edition 1.20.

Related commands