coretweaks 指令

[!INFO] 实现类:makamys.coretweaks.command.CoreTweaksCommand(继承 net.minecraft.command.CommandBase) 接口:makamys.coretweaks.command.ISubCommand

⚠️ 当前版本无法使用(被硬编码关闭)

// @ConfigBoolean(cat="Diagnostics", def=TRUE, com="Enables the /coretweaks command, used to access various
// diagnostics. Invoke it in-game for additional information.")
public static FeatureSetting coreTweaksCommand = FeatureSetting.FALSE;

Config.coreTweaksCommand 的配置注解被注释,字段硬编码为 FeatureSetting.FALSE,isActive() 恒 false。 CoreTweaksMod.init() 中的注册代码因此是死代码:

if (Config.coreTweaksCommand.isActive()) {
    ClientCommandHandler.instance.registerCommand(new CoreTweaksCommand());
}

⚠️ 注意注册用的是 ClientCommandHandler —— 即该指令本来也只面向客户端。

指令规格

属性 值
指令名 coretweaks
权限等级 getRequiredPermissionLevel() 返回 0(任何人可用)
用法字符串 getCommandUsage 返回空串 ""
注册方式 ClientCommandHandler.instance.registerCommand(...)

子命令分发

CoreTweaksCommand 用 Map<String, ISubCommand> 静态注册子命令:

private static final Map<String, ISubCommand> subCommands = new HashMap<>();

public static void register(String key, ISubCommand command) {
    subCommands.put(key, command);
}

processCommand 按 args[0] 查表:

ISubCommand subCommand = subCommands.get(args[0]);
// … 执行
throw new WrongUsageException("coretweaks <" + String.join("|", subCommands.keySet()) + ">", new Object[0]);

无参数或子命令名非法时,异常消息会动态列出全部已注册子命令名 (以 | 分隔)。这意味着子命令集合完全由静态注册决定, 源码中无硬编码的子命令清单。

⚠️ 本仓源码中没有任何地方调用 CoreTweaksCommand.register(...) (无其它类传入 ISubCommand 实现)。因此 subCommands 映射表在当前版本 为空,/coretweaks 即使被启用也会因 args[0] 查不到而抛 WrongUsageException 并显示 coretweaks <>。

即该指令是双重不可用:既不被注册,注册后也无子命令。

同分类的其它 Diagnostics 功能

与本指令同属 Diagnostics 配置分类但可用的有:

功能 门控 状态
enhanceMapStorageErrors MixinMapStorage ✅ 默认开启
detectDataWatcherIdConflicts MixinDataWatcher ✅ 默认开启
coreTweaksCommand 本页 ❌ 硬编码 FALSE

详见 Diagnostics Mixin。

相关条目