Visit the new site! Link Search Menu Expand Document

Understanding .mcfunction

Table of contents
  1. Understanding .mcfunction
  2. Running functions through tick.json
    1. Creating tick.json
    2. Warning

mcfunction files are stored in your BP as BP/functions/my_function.mcfunction. You can add as many functions as you like.

Functions are used to group multiple Minecraft commands (such as /say or /teleport) into managable chunks (or functions). Function files do not begin with /.

Example:

tag @s add dev
gamemode creative
effect @s night_vision 100000 1 true

Functions can be executed in game by typing /function name_of_function. This will execute all the commands in the function file, all in a single tick. Nested functions will also run in the same tick as the parent function.

Function files can be nested, for example: BP/functions/teleport/home.mcfunction will create a new function called teleport/home, which can be called in game like /function teleport/home.

Functions can be reloaded from file without leaving the game with the /reload command.

Running functions through tick.json

tick.json is server-side file located as BP/functions/tick.json that lets you execute function files.

Functions will be run each tick, as if placed in a repeating command block.

Creating tick.json

Create a file called tick.json in your root function folder. The format is this:

{
    "values": [
        "function_file_name_one",
        "function_file_name_two"
    ]
}

Warning

Functions triggered within tick.json will execute commands before the player has joined the world, so make sure your commands don’t break the game if they aren’t able to locate players.