Minecraft /function command

Java EditionBedrock EditionSince Java 1.12 (17w18a) / Bedrock 1.8.0

Quick answer: Runs every command inside a function file, in order, instantly. Syntax: function <name>

/function executes a .mcfunction file from a data pack (Java) or behavior pack (Bedrock): a plain list of commands, one per line, run in sequence as if typed. Functions are how maps and data packs organize logic - setups, timers, events - and they accept no arguments in vanilla. Combine with /schedule for delayed or repeating runs.

Syntax

EditionSyntax
Javafunction <name>
Bedrockfunction <name: filepath>

Targets / arguments: A function file or, in Java, a function tag (#namespace:tag). Requires: Cheats enabled / operator level 2 (Java), 1 (Bedrock).

Examples

/function mypack:setup/arena

Java: run the setup/arena function from the mypack data pack

/function #mypack:tick

Java: run every function in the tick tag

/function events/start_game

Bedrock: run the start_game function from a behavior pack

Tips

Related commands

/schedule/execute