-
Notifications
You must be signed in to change notification settings - Fork 1
Home
A Fabric mod for Minecraft 1.21.11 that lets server operators create custom slash commands that execute datapack functions. Commands are registered at runtime, persist across server restarts and /reload, and appear in tab completion for all players immediately — no restart required.
Datapack-Commands acts as a bridge between players and datapack functions. Normally, players cannot run datapack functions directly — only operators can use /function. This mod lets operators pre-register shortcuts so players can trigger functions with simple, friendly commands.
When a command is created:
- It is registered into Minecraft's command tree (Brigadier) immediately
- It is saved to
datapackcommands.jsonin the world folder - All online players receive an updated command tree so tab completion works right away
- On every server start and
/reload, saved commands are automatically re-registered
- Install [Fabric Loader](https://fabricmc.net/) for Minecraft 1.21.11
- Install [Fabric API](https://modrinth.com/mod/fabric-api)
- Drop the mod
.jarinto yourmods/folder - Start your server
No configuration is needed. The mod creates datapackcommands.json automatically in your world folder the first time a command is registered.
All /cgen subcommands require operator level 4. Custom commands created with the mod are available to all players.
Registers a new custom command that executes a datapack function.
Syntax:
/cgen create <commandname> <namespace:function>
/cgen create "<command> <subcommand>" <namespace:function>
-
<commandname>— the name of the new command (single word, no spaces) -
"<command> <subcommand>"— a quoted multi-word command path -
<namespace:function>— the datapack function to run, innamespace:pathformat
Rules:
- Command names are case-sensitive
- You cannot register a command that already exists — use
/cgen removefirst - The datapack function does not need to exist at registration time, but the command will silently do nothing if it doesn't exist when run
Examples:
/cgen create spawn utils:teleport_spawn
/cgen create heal utils:heal_player
/cgen create day utils:set_daytime
/cgen create night utils:set_nighttime
/cgen create weather_clear utils:clear_weather
Unregisters a custom command immediately.
Syntax:
/cgen remove <commandname>
- Tab complete will suggest all currently registered commands after typing
/cgen remove - For multi-word commands, type the full path (e.g.
tp creative) - Removing a root command (e.g.
tp) also removes all its subcommands from the tree
Examples:
/cgen remove spawn
/cgen remove heal
/cgen remove tp creative
Note: If you registered /tp creative and /tp survival as separate commands, removing tp creative only removes that specific entry from the save file. However, because Brigadier manages the tree as a whole, the root /tp node is what gets unregistered — meaning /tp survival will also stop working until the next /reload or restart, at which point it re-registers from the save file.
Lists all currently registered commands and the functions they map to.
Syntax:
/cgen list
Example output:
Registered commands:
/spawn -> utils:teleport_spawn
/heal -> utils:heal_player
/tp creative -> gamemode:set_creative
/tp survival -> gamemode:set_survival
Controls whether a confirmation message appears in chat when a player runs a custom command. Defaults to off.
Syntax:
/cgen feedback
/cgen feedback on
/cgen feedback off
-
feedbackwith no argument — shows the current state -
feedback on— players see"Executed function: namespace:path"after running a command -
feedback off— commands run silently (default)
This setting is saved to datapackcommands.json and persists across restarts.
Example with feedback on:
> /spawn
Executed function: utils:teleport_spawn
Example with feedback off:
> /spawn
(nothing shown)
Note: Messages sent by the datapack function itself (via tellraw, say, title, etc.) are always shown regardless of this setting. Feedback only controls the "Executed function: ..." line added by the mod and the vanilla "Running function ..." system message.
Sanity check to verify the mod is running.
Syntax:
/cgen check
Returns 1 in chat if the mod is loaded and functioning correctly. Useful for datapacks that need to check whether the mod is active.
Datapack-Commands supports registering commands with subcommands by wrapping the full command path in quotes.
Syntax:
/cgen create "<root> <sub>" <namespace:function>
/cgen create "<root> <sub> <subsub>" <namespace:function>
Each space-separated token becomes a fixed literal subcommand in the Brigadier tree. Minecraft will tab-complete each level automatically.
Example — gamemode shortcuts:
/cgen create "gm creative" gamemode:set_creative
/cgen create "gm survival" gamemode:set_survival
/cgen create "gm adventure" gamemode:set_adventure
/cgen create "gm spectator" gamemode:set_spectator
Players can now type /gm and Tab to see creative, survival, adventure, spectator as suggestions.
Example — time shortcuts:
/cgen create "time day" world:set_day
/cgen create "time noon" world:set_noon
/cgen create "time night" world:set_night
/cgen create "time midnight" world:set_midnight
Example — three levels deep:
/cgen create "buff speed fast" buffs:speed_fast
/cgen create "buff speed slow" buffs:speed_slow
/cgen create "buff jump high" buffs:jump_high
Players run /buff speed fast or /buff jump high.
Removing multi-word commands:
/cgen remove gm creative
/cgen remove time day
/cgen create spawn world:teleport_spawn
/cgen create heal player:restore_health
/cgen create feed player:restore_hunger
/cgen create day world:set_day
/cgen create night world:set_night
/cgen create clear world:clear_weather
/cgen create rain world:set_rain
/cgen create "gm c" gamemode:creative
/cgen create "gm s" gamemode:survival
/cgen create "gm a" gamemode:adventure
/cgen create "gm sp" gamemode:spectator
/cgen create startgame minigame:start
/cgen create endgame minigame:end
/cgen create resetarena minigame:reset_arena
/cgen create givekits minigame:distribute_kits
/cgen create "shop tier1" shop:buy_tier1
/cgen create "shop tier2" shop:buy_tier2
/cgen create "shop tier3" shop:buy_tier3
/cgen create "event halloween" events:start_halloween
/cgen create "event christmas" events:start_christmas
/cgen create "event off" events:disable_all
Commands are saved to a JSON file inside your world folder:
world/datapackcommands.json
Example file contents:
{
"commands": {
"spawn": "utils:teleport_spawn",
"heal": "utils:heal_player",
"tp creative": "gamemode:set_creative",
"tp survival": "gamemode:set_survival"
},
"feedbackEnabled": false
}- Each world has its own independent set of commands
- Switching to a different world folder will load that world's commands instead
- You can manually edit this file while the server is stopped, but do not edit it while the server is running
- Deleting the file removes all registered commands on next restart
-
No dynamic arguments — subcommands are fixed literals only. You cannot create a command like
/tp <player>where<player>is a variable. Each variation must be registered as its own command path. - No permission levels per command — all custom commands are available to every player. Permission management must be handled inside the datapack function itself (e.g. checking scores or tags).
- Datapack function is not validated — if the function does not exist when the command is run, Minecraft will silently do nothing. Make sure your datapack is loaded before registering commands that depend on it.
-
Removing a root unregisters the whole tree — if you registered
/tp creativeand/tp survivaland remove one of them, both subcommands disappear from Brigadier until the next/reloador restart, at which point remaining entries re-register from the save file. -
The datapack's own messages cannot be silenced —
/cgen feedback offsuppresses the mod's own messages and the vanillaRunning function ...line, but anytellraw,say, ortitleinside the function will always show.