DatapackJavaBedrock

/function

Run a datapack function file.

What is /function used for?

What /function is for

Runs all the commands in a datapack function file (.mcfunction), in order, in one call.

When to use /function

Bundle complex command sequences into reusable, named routines — the building block of datapacks, called by tick/load tags, /schedule, or other functions.

Syntax

Parameters

name
function ID
Namespaced function, e.g. mypack:setup.

Command builder

Configure the options below to generate a ready-to-paste /function command.

Form namespace:path, e.g. mypack:setup.

Examples

  • Run mypack/data/mypack/functions/setup.mcfunction.

Common questions

How do I run a datapack function?

Use /function <namespace>:<path>, e.g. /function mypack:setup runs mypack/data/mypack/functions/setup.mcfunction.

How do I run a function automatically?

Add it to the minecraft:tick or minecraft:load function tag in your datapack, or queue it with /schedule.

Permission level

/function requires Cheats (op level 2). In single-player you need the world's "Allow Cheats" toggle on. On a multiplayer server you need to be opped — see /op.