Wiki 9Minecraft Wiki 9Minecraft

Commands and functions

Build working command lines without counting brackets.

10Tools
6Reference pages
4Things to get right

Commands are the quickest way to make something happen in a world, and function files are just lists of commands a data pack can run. The hard part is the syntax, so let a generator write it.

Four things to get right first

Selectors do most of the work

@e[type=zombie,distance=..10,limit=3,sort=nearest] is the difference between a command that works and one that hits everything in the world. Narrow the selector before you worry about the rest.

Components replaced NBT on items

Modern versions give items data components such as [custom_name='"Hammer"'] instead of the old NBT blob. Old guides on the internet still use the NBT form and will not run.

A function file is just commands, one per line

Drop it at data/yourname/function/thing.mcfunction and call it with /function yourname:thing. No brackets, no JSON.

Chain with execute rather than with more command blocks

One /execute as … at … run … replaces a row of command blocks and is far easier to read a month later.

Tools that do the work

Reference, straight from the game files

Read out of the game with Mojang’s own data generator, so it matches the version exactly.

Other things you can make