Commands/function

From Minecraft Wiki
Jump to: navigation, search
Java Edition.pngMclogo.svg
function
Restrictions

Operator

First introduced

Java Edition 1.12 (Java Edition 1.12-pre1 )

Runs a function.

Syntax
  • Java Edition
function <function>
Arguments
function
Must be of the format namespace:path/to/function/file.
Result
Fails if the argument is not specified correctly.
If successful, runs a function through the entity or commandblock which ran the /function command.
Examples
To run a function located at 'data/functions/custom/example/test.mcfunction': function custom:example/test
To run a function if there is a sheep within a radius of 2 blocks: execute if entity @e[type=sheep,distance=..2] run function custom:example/test
To run a function unless the executor is a player: execute unless entity @s[type=player] run function custom:example/test
See also
Tag – To run a function every tick.

History[edit]

Java Edition
1.12 pre1 Added /function.
Bedrock Edition
1.8 beta 1.8.0.8 Added /function.