Functions System
Chain multiple commands together using .mcfunction files for complex command sequences.
What Are Functions?
Functions allow you to execute multiple commands in sequence from a single alias. Instead of running one command, your alias can reference a .mcfunction file that contains a list of commands to run one after another.
This is perfect for complex operations like:
- Server announcements with multiple effects
- Multi-step setup processes
- Chained game mechanics
- Automated sequences
How It Works
The Functions folder (config/CommandMaker/Functions/) is automatically created when the mod loads. An example function file is also created for you.
✨ Automatic Alias Creation
NEW: Aliases are now automatically created for any .mcfunction file! If you create mobsoff.mcfunction, the command /mobsoff will automatically work without needing to edit aliases.json.
Step 1: Create a Function File
Create a .mcfunction file in config/CommandMaker/Functions/
Example: mobsoff.mcfunction
spawn rates monster 0
say Monster spawns disabled!
Step 2: Use It In-Game (Automatic!)
/mobsoff
The alias is automatically created - no manual configuration needed!
Manual Alias Creation (Optional)
If you want custom alias names or additional configuration, you can still manually add aliases in aliases.json:
{
"mobsoff": "function:mobsoff",
"disable_mobs": "function:mobsoff" // Custom alias name
}
Function File Format
- Each line is a separate command
- Empty lines and lines starting with # are ignored
- Variables like ${player}, ${x}, ${y}, ${z} work in functions
- Commands execute in the order they appear
Example Function: server_restart.mcfunction
# Announce the restart
say §c[SERVER] Server restarting in 30 seconds!
# Save the world
save-all
# Wait 30 seconds (using schedule if available)
schedule function minecraft:restart_warning 25s
# Actually restart (this would need a restart command or plugin)
# stop
Advanced Usage
Variables in Functions
All variables work in function files:
tp ${player} 0 100 0
say ${player} has been teleported to spawn!
Conditional Logic
Use Minecraft's conditional commands:
execute if entity @a[name=Admin] run say Admin is online!
execute unless entity @a[name=Admin] run say Admin is offline!
Troubleshooting
- Make sure the .mcfunction file exists in the Functions folder
- Check that the filename matches exactly (case-sensitive)
- Verify commands are valid Minecraft commands
- Use
/cmd reloadafter editing files