How to run a function in Minecraft
Type /function mypack:start in chat as an operator to run the commands in the start.mcfunction file of that data pack.
function
Runs a function from a data pack: a list of commands stored in a .mcfunction file.
/function <name> [<arguments>|with <block <pos>|entity <target>|storage <id>> [<path>]] Examples
/function mypack:start Runs one function.
/function mypack:give_kit {item:"minecraft:iron_sword"} Runs a macro function with an argument.
/function #mypack:reset Runs every function in a tag.
Arguments
nameRequired- Function ID or
#tag. argumentsOptional- Macro arguments as an NBT compound.
What it does
Functions are named namespace:path, and #namespace:tag runs every function in a function tag. Macro functions take arguments as an NBT compound or with a block, entity or storage. Functions run with the permission level set by function-permission-level in server.properties.
Good to know
- Needs operator permission level 2.
- After editing a function file, run
reloadto load the change.
Run it on your server
On a SLASHPLAY server, type it in the Console tab without the leading slash; in game, operators type it in chat with the slash. New to this? Start a Minecraft server first.
Your own
Minecraft server.
From $0.03 an hour, only while it runs. New accounts get 6 free tokens.