Function (Java Edition)

Functions are an upcoming feature that will allow players to easily script lists of commands using text files.

Usage
To use functions in a Minecraft world, the text files must first be placed into the  folder. They can then be run using the several methods detailed below. Functions can be further divided into subfolders, and are run in-game using the format. For example, running  will refer to the function located at.

Within the text file, one valid command is placed per line. Players can place comments within the function text file, using  or. If a function is added or modified, the command will reload the function files and run the new commands. Commands run inside a function will obey.

Since they are simply text files, functions are easily modifiable and less likely to induce lag when used in large quantities, compared to command blocks. However, the successful output of a function cannot be measured with a comparator (without the use of complex scoreboard commands), nor is there a "conditional" argument for functions.

There are currently three ways of running a function file in-game:

/function
The command allows players to run a function once. The commands in the function are run through the entity or command block that ran the command.

Usage:

/gamerule gameLoopFunction
The will run a function every tick. The commands in the function are run through the server.

Usage:

Advancement rewards
Advancements can run a function once as a reward for completing them. The commands in the function are run through the player who completed the advancement.

Usage:

{    "rewards": { "function": "namespace:path/to/function/file" } }