Commands/function

Runs a function.


 * Syntax


 * Java Edition


 * Arguments


 * function


 * Must be of the format.




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




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


 * selector


 * When used with  or , 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.
 * Fails if the selector was found using.


 * 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.