Function (Bedrock Edition)

Functions allow players to run lists of commands using text files with the extension. This page covers how to use Functions in Bedrock Edition.

For how to use Functions in Java Edition please see Function.

Usage
Text files must be placed into a top-level folder named "functions" within a behavior pack: `[behavior_pack_root]/functions`

Subfolders and Namespacing
Subfolders can be added to this folder to serve as namespaces.

For example: running the function  will run the file located at.

/reload
Note: Currently /reload will only reload mcfunctions that already exist at the time the game is launched. Meaning you can make changes to existing functions but will need to restart the game for newly added functions. This will change in future updates of Minecraft.

Success Results:
Upon successfully running a function, a message will display in chat: "Executed [amount] Command(s) from function ."

Function Syntax
Within the  file, one valid command is placed per line, without the usual forward slash. Players can add comments within the function text file by preceding them with a.

min_engine_version
Functions require a minimum engine version specified in the pack manifest.json file.

This field determines which version of a command to run. The number specified here should match the version number of the game. For example, lets say that /fill was changed in. If your behavior pack has  and runs a function that contains /fill, it will run the older version of fill (as if the version was still  ).

Manifest Example:
{   "format_version": 1, "header": { "description": "Functions!", "name": "Function Behavior Pack", "uuid": "11111111-1111-1111-1111-111111111111", "version": [0, 0, 1], "min_engine_version": [1, 8, 0] },   "modules": [ {           "description": "", "type": "data", "uuid": "22222222-2222-2222-2222-222222222222", "version": [0, 0, 1] }   ] }

Simple Function Example:
HelloWorld.mcfunction

say hello fill ~ ~2 ~ ~ ~2 ~ gold_block say world
 * 1) this is a comment

More Complex Function Example:
BuildHut.mcfunction - this function builds a basic stone and wood house around you. Note that because the function runs commands in order, that the glass windows and wooden door will replace the stone walls created by the first command.

fill ~-2 ~-1 ~-2 ~2 ~2 ~2 stonebrick 0 hollow fill ~-2 ~-1 ~-2 ~2 ~-1 ~2 planks fill ~ ~ ~2 ~ ~ ~2 wooden_door 1 fill ~-2 ~1 ~ ~-2 ~1 ~ glass fill ~2 ~1 ~ ~2 ~1 ~ glass fill ~ ~1 ~-2 ~ ~1 ~-2 glass

Running a Function
Functions will attempt to run all commands within a single tick, including the commands of nested functions called within another function.

Limits
A single function call will only run up to 10,000 commands (including calls to other functions, i.e. recursion).

Running  from above will output:
 * Chat output: [your name]: hello
 * Fill the block above your head with a gold_block
 * Chat output: [your name ]: world


 * Allows players to run a function once
 * The commands in the function are run through the entity or command block that ran the  command.
 * Bedrock does not currently support  and
 * Usage: