Skip to main content

Logic Commands

Commands for scheduling functions, spawning particles, and playing sounds.

/function
Game Master

Runs a function or function tag from a data pack. Functions are .mcfunction files containing a list of commands.

v1.12
/particle
Game Master

Spawns particles at a location. Supports all particle types with customizable spread, speed, and visibility.

v1.8
/playsound
Game Master

Plays a sound effect to one or more players. Supports all vanilla and custom sounds with volume and pitch control.

v1.6.1
/schedule
Game Master

Schedules a function to run after a specified delay. Can also clear previously scheduled functions.

v1.14

Functions

A function is a .mcfunction file inside a data pack, one command per line. Since Java 1.21 the folder is called function; packs made for older versions use functions, with an s, and that is the first thing to check when an old pack seems to do nothing. /function runs one function by its id, or every function in a tag when you put # in front.

One line that fails to parse is enough to stop the whole file from loading, so look in the server log after /reload when a function has gone missing. Lines that start with $ are macro lines, available since 1.20.2. They fill in $(key) from a compound you pass, either inline as in /function mypack:greet {name:"Alex"} or read from a block, entity or storage with with.

Delays

/schedule function runs a function later. The delay takes t, s or d, and there is no unit for minutes, so five minutes is 300s. A new schedule replaces a pending one for the same function unless you add append. The run always happens as the server at world spawn, even if you scheduled it from inside execute as, so select your entities inside the function.

Particles and sounds

/particle shows an effect to players within 32 blocks. With force that becomes 512 blocks, and players who turned particles down to Minimal see it anyway, so keep force for effects that matter. A count of 0 spawns a single particle and uses the delta values times the speed as its motion. That is how you shoot one in a direction.

/playsound takes a source category, and the category decides which volume slider a player can turn it down with: master, music, record, weather, block, hostile, neutral, player, ambient, voice or ui. Since 1.20.5 the source and the target may be left out; the sound then plays under master to whoever ran the command. A volume above 1 is not louder. It carries further instead, 16 blocks for every point of volume. Pitch goes up to 2.0, and anything below 0.5 plays at 0.5.

All four commands need permission level 2.