配置系统

ConfigHandler

glowredman.biomebridge.ConfigHandler 负责从 config/biomesoplenty/ 目录读取 Biomes O’ Plenty 的配置文件,进行备份,并将配置值暴露为 public static 字段供全模组访问。

包: glowredman.biomebridge 源文件: src/main/java/glowredman/biomebridge/ConfigHandler.java

构造与初始化

ConfigHandler(Path configDir)
// configDir = event.getModConfigurationDirectory().toPath()

构造时接收配置文件目录路径,存储为 CONFIG_DIR 字段。

配置导入流程

1. structures/strongholds.cfg

读取要塞配置目录,将 allow strongholds 类目下的布尔属性解析为 Set<String> biomesAllowingStrongholds。

2. structures/villages.cfg

读取村庄配置目录,将 allow villages 类目下的布尔属性解析为 Set<String> biomesAllowingVillages。

3. biomegen.cfg

读取生态群系生成配置,解析以下 5 个类目的布尔属性:

  • end biomes to generate
  • nether biomes to generate
  • overworld (river) biomes to generate
  • overworld (sub) biomes to generate
  • overworld biomes to generate

合并结果写入 Set<String> enabledBiomes;同时解析 vanilla biomes to override 写入 Set<String> enabledBiomeOverrides。

4. biomeweights.cfg

读取生态群系权重配置,遍历以下类目所有条目:

  • end biome weights
  • nether biome weights
  • overworld biome weights

将每个条目的 key(生态群系名)与其 int 值(权重)存入 Map<String, Integer> BIOME_WEIGHTS。

5. ids.cfg

读取 ID 配置,解析 biome ids 类目下所有条目,key → int 值存入 Map<String, Integer> BIOME_IDS;同时读取药水 ID:

paralysisID = idsCfg.get("potions ids", "Paralysis Potion ID", 20).getInt();
possessionID = idsCfg.get("potions ids", "Possession Potion ID", 21).getInt();
autoAssignPotions = idsCfg.get("potion auto assign", "Potion Auto Assign", true).getBoolean();

6. main.cfg

读取主配置,获取调试和怪物生成设置:

enableDebug        = mainCfg.get("debug settings", "Debug Mode", false).getBoolean();
spawnAll          = mainCfg.get("mob settings", "Spawn all mobs", true).getBoolean();
spawnGlob         = mainCfg.get("mob settings", "Spawn Glob", true).getBoolean();
spawnJungleSpider = mainCfg.get("mob settings", "Spawn Jungle Spider", true).getBoolean();
spawnPhantom      = mainCfg.get("mob settings", "Spawn Phantom", true).getBoolean();
spawnPixie        = mainCfg.get("mob settings", "Spawn Pixie", true).getBoolean();
spawnRosester     = mainCfg.get("mob settings", "Spawn Rosester", true).getBoolean();

7. misc.cfg

读取杂项配置:

enableFogColors              = miscCfg.get("hard-coded colors", "Enable Fog Colors", true).getBoolean();
enableSkyColors              = miscCfg.get("hard-coded colors", "Enable Sky Colors", true).getBoolean();
addCustomDungeonLoot         = miscCfg.get("miscellanious settings", "Add Custom Dungeon Loot", true).getBoolean();
enableSpecialEvents          = !miscCfg.get("miscellanious settings", "Behave Normally During Special Events", true).getBoolean();
enableMainMenuPanorama      = miscCfg.get("miscellanious settings", "Enable Biomes O' Plenty Main Menu Panorama", true).getBoolean();
enablePoisonIvyEffects      = miscCfg.get("miscellanious settings", "Enable Poison Ivy Effects", true).getBoolean();
enableSpringWaterRegenEffect= miscCfg.get("miscellanious settings", "Enable Spring Water Regeneration Effect", true).getBoolean();
onlySpawnOnBeaches          = miscCfg.get("spawn settings", "Only Spawn On Beaches", true).getBoolean();
spawnLocationSearchRadius    = miscCfg.get("spawn settings", "Spawn Location Search Radius", 1024).getInt();

注意 enableSpecialEvents 通过取反实现:Behave Normally During Special Events = true 时 enableSpecialEvents = false。

8. terraingen.cfg

读取地形生成配置:

biomeSize           = terraingenCfg.get("biomes o' plenty world type settings", "Biome Size", 4).getInt();
landmassPercentage  = terraingenCfg.get("biomes o' plenty world type settings", "Landmass Percentage", 10).getInt();
oceanFiller         = terraingenCfg.get("biomes o' plenty world type settings", "OceanFiller", true).getBoolean();
enableOreGen        = terraingenCfg.get("biomes o' plenty world type settings", "OreGeneration", true).getBoolean();
generateAmber       = terraingenCfg.get("biomes o' plenty world type settings", "genAmberOre", true).getBoolean();
generateAmethyst    = terraingenCfg.get("biomes o' plenty world type settings", "genAmethystOre", true).getBoolean();
generateMalachite    = terraingenCfg.get("biomes o' plenty world type settings", "genMalachiteOre", true).getBoolean();
generatePeridot     = terraingenCfg.get("biomes o' plenty world type settings", "genPeridotOre", true).getBoolean();
generateRuby        = terraingenCfg.get("biomes o' plenty world type settings", "genRubyOre", true).getBoolean();
generateSapphire    = terraingenCfg.get("biomes o' plenty world type settings", "genSapphireOre", true).getBoolean();
generateTanzanite   = terraingenCfg.get("biomes o' plenty world type settings", "genTanzaniteOre", true).getBoolean();
generateTopaz       = terraingenCfg.get("biomes o' plenty world type settings", "genTopazOre", true).getBoolean();
generateWaspHives   = terraingenCfg.get("biomes o' plenty world type settings", "genWaspHives", true).getBoolean();

readConfig() 状态

void readConfig() 方法当前为空实现(TODO),尚未从 BiomeBridge 自有配置文件读取任何配置。

备份机制

每个配置文件读取后立即调用 backup(Path path) 备份原始文件,确保配置迁移过程可回溯。

相关链接