Commands/function

Runs a function.


 * Syntax


 * Java Edition


 * Arguments


 * function


 * Must be of the format.


 * if


 * Will only make the function run when an entity was found matching the selector.


 * unless


 * Will only make the function run when no entity was found matching the selector.


 * selector


 * When used with if or unless, this determines the entity to find or not find for the function to actually run.


 * Result


 * Fails if the argument is not specified correctly.


 * Fails if the selector was not found using if.


 * Fails if the selector was found using unless.


 * 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':


 * To run a function if there is a sheep within a radius of 2 blocks:


 * To run a function unless the executor is a player:


 * See also


 * gamerule gameLoopFunction – Runs a function every tick.