跳到正文

Datapack Commands

A Datapack Tool that allows datapacks to have custom commands

收藏

介绍

中文介绍正在准备中,下面暂时显示原文。

Datapack Commands Logo

A Fabric mod for Minecraft 1.21.11 that lets datapack creators create custom slash commands that execute datapack functions. Commands are registered at runtime, persist across restarts, and show up in tab completion for all players — no server restart required.


How to Use

All management is done through the /cgen command, which requires operator level 4.

Creating a command

/cgen create <commandname> <namespace:function>

(Subcommands are also possible)

/cgen create "<commandname> <arg> <etc>" <namespace:function>

Registers a new /<commandname> that runs the specified datapack function when used. The command is available to all players immediately. If using a subcommand make sure to add a ” around the main command and subcommand

Example:

/cgen create ""spawn zombie"" example:spawn_zombie

Players can now run /spawn zombie and it will execute example:spawn_zombie.


Removing a command

/cgen remove <commandname>

Unregisters the command immediately. Tab complete will suggest your registered commands after typing /cgen remove.

Example:

/cgen remove spawn

Listing commands

/cgen list

Shows all currently registered commands and the functions they map to.

Example output:

Registered commands:
  /fasterpathsload -> fasterpaths:load
  /heal -> utils:heal_player

Feedback toggle (default is off)

/cgen feedback on
/cgen feedback off

Controls whether the "Executed function: ..." message appears in chat when a player runs a custom command. Defaults to off. This setting persists across restarts.


Check

/cgen check

Returns 1 if the mod is running correctly. Useful for datapacks that want to verify that the mod is loaded.


Notes

  • Commands are saved to <world folder>/datapackcommands.json and automatically re-registered on server start.
  • The datapack function itself can still send its own chat messages (e.g. via tellraw) regardless of the feedback setting.
  • Command names must be alphanumeric with underscores, up to 32 characters.
  • Function names must follow the standard namespace:path format.

常见问题

Datapack Commands 支持哪些 Minecraft 版本?

Datapack Commands 支持 Minecraft Java 版 1.20.5–26.1.2,共 17 个版本,可用的加载器:Fabric。下载时注意选择和你游戏版本一致的文件。

Datapack Commands 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。

评论

登录后评论和评分