/dumpOredict 指令

把当前世界中全部已注册的 OreDict 名称导出成文本文件。

  • 类:iguanaman.iguanatweakstconstruct.commands.CommandDumpOredict
  • 权限等级:2(OP)
  • 用法:/dumpOredict
  • 输出文件:游戏根目录下的 dump_OreDict.txt

实现

File file = new File("dump_OreDict.txt");
try {
    PrintWriter pw = new PrintWriter(file);
    for (String ore : OreDictionary.getOreNames()) pw.println(ore);
    pw.close();
    icommandsender.addChatMessage(new ChatComponentText("Dumped oredict names to " + file.getName()));
} catch (FileNotFoundException e) {
    Log.error("Couldn't create file " + file.getName());
    icommandsender.addChatMessage(new ChatComponentText("Couldn't create file " + file.getName()));
}
  • 每个 OreDict 名称一行,不做排序(与 /dumpTools 不同)
  • 成功后聊天栏提示 Dumped oredict names to dump_OreDict.txt
  • 文件路径是相对路径(相对于服务端工作目录)

用途

挖掘等级系统 通过「8 个前缀 × 10 档材料名」拼接出的组合来设置方块挖掘等级,核心实现:

private static String[] oreDictPrefixes = { "ore", "denseore", "oreNether", "denseoreNether",
                                            "block", "stone", "brick", "orePoor" };

/dumpOredict 的输出可用于:

  1. 找出整合包中某个 mod 使用的非标准 OreDict 名,以便加进 BlockOverride.cfg 的 oredict 分类;
  2. 验证 orePoor(Poor ores)、denseore(致密矿)等前缀在本整合包中是否真的被使用;
  3. 排查某个方块挖掘等级不对的原因(其 ore 名是否被正确登记)。

失败处理

FileNotFoundException 时记日志 + 聊天栏报错,不抛异常。

相关