Search in sources :

Example 1 with FileConfigManager

use of buildcraft.lib.config.FileConfigManager in project BuildCraft by BuildCraft.

the class BuildCraftCore method loadConfiguration.

@Mod.EventHandler
public void loadConfiguration(FMLPreInitializationEvent evt) {
    BCLog.logger.info("Starting BuildCraft " + DefaultProps.VERSION);
    BCLog.logger.info("Copyright (c) the BuildCraft team, 2011-2016");
    BCLog.logger.info("http://www.mod-buildcraft.com");
    new BCCreativeTab("main");
    commandBuildcraft.addAlias("bc");
    commandBuildcraft.addChildCommand(new SubCommandDeop());
    commandBuildcraft.addChildCommand(new SubCommandOp());
    BuildcraftRecipeRegistry.assemblyTable = AssemblyRecipeManager.INSTANCE;
    BuildcraftRecipeRegistry.integrationTable = IntegrationRecipeManager.INSTANCE;
    BuildcraftRecipeRegistry.refinery = RefineryRecipeManager.INSTANCE;
    BuildcraftRecipeRegistry.programmingTable = ProgrammingRecipeManager.INSTANCE;
    BuilderAPI.schematicHelper = SchematicHelper.INSTANCE;
    BuilderAPI.schematicRegistry = SchematicRegistry.INSTANCE;
    File cfgBase = new File(evt.getModConfigurationDirectory(), "buildcraft");
    BCRegistry.INSTANCE.setRegistryConfig(new File(cfgBase, "objects.cfg"));
    mainConfiguration = new Configuration(new File(cfgBase, "main.cfg"));
    detailedConfigManager = new FileConfigManager(" The buildcraft detailed configuration file. This contains a lot of miscelaneous options that have no " + "affect on gameplay.\n You should refer to the BC source code for a detailed description of what these do. " + "(https://github.com/BuildCraft/BuildCraft)\n" + " This file will be overwritten every time that buildcraft starts, so there is no point in adding comments");
    detailedConfigManager.setConfigFile(new File(cfgBase, "detailed.properties"));
    ConficGuiFactoryBC.setConfig(mainConfiguration);
    mainConfiguration.load();
    ConficGuiFactoryBC.getCat("debug").setShowInGui(false);
    ConficGuiFactoryBC.getCat("vars").setShowInGui(false);
    ConficGuiFactoryBC.register("general.useServerDataOnClient", BuildCraftCore.useServerDataOnClient, "Allows BuildCraft to use the integrated server's data on the client on singleplayer worlds. Disable if you're getting the odd crash caused by it.", RestartRequirement.NONE);
    ConficGuiFactoryBC.register("general.builderMaxIterationsPerItemFactor", BuildCraftCore.builderMaxPerItemFactor, "Lower this number if BuildCraft builders/fillers are causing TPS lag. Raise it if you think they are being too slow.", RestartRequirement.NONE);
    ConficGuiFactoryBC.register("general.miningBreaksPlayerProtectedBlocks", false, "Should BuildCraft miners be allowed to break blocks using player-specific protection?", RestartRequirement.NONE);
    ConficGuiFactoryBC.register("general.updateCheck", true, "Should I check the BuildCraft version on startup?", RestartRequirement.NONE);
    ConficGuiFactoryBC.register("display.hidePowerValues", false, "Should all power values (RF, RF/t) be hidden?", RestartRequirement.NONE);
    ConficGuiFactoryBC.register("display.hideFluidValues", false, "Should all fluid values (mB, mB/t) be hidden?", RestartRequirement.NONE);
    ConficGuiFactoryBC.register("general.itemLifespan", 60, "How long, in seconds, should items stay on the ground? (Vanilla = 300, default = 60)", RestartRequirement.NONE).setMinValue(5);
    ConficGuiFactoryBC.register("network.updateFactor", 10, "How often, in ticks, should network update packets be sent? Increasing this might help network performance.", RestartRequirement.GAME).setMinValue(1);
    ConficGuiFactoryBC.register("network.longUpdateFactor", 40, "How often, in ticks, should full network sync packets be sent? Increasing this might help network performance.", RestartRequirement.GAME).setMinValue(1);
    ConficGuiFactoryBC.register("general.canEnginesExplode", false, "Should engines explode upon overheat?", RestartRequirement.NONE);
    ConficGuiFactoryBC.register("worldgen.enable", true, "Should BuildCraft generate anything in the world?", RestartRequirement.GAME);
    ConficGuiFactoryBC.register("general.pumpsConsumeWater", false, "Should pumps consume water? Enabling this might cause performance issues!", RestartRequirement.NONE);
    ConficGuiFactoryBC.register("power.miningUsageMultiplier", 1.0D, "What should the multiplier of all mining-related power usage be?", RestartRequirement.NONE);
    ConficGuiFactoryBC.register("display.colorBlindMode", false, "Should I enable colorblind mode?", RestartRequirement.GAME);
    ConficGuiFactoryBC.register("worldgen.generateWaterSprings", true, "Should BuildCraft generate water springs?", RestartRequirement.GAME);
    ConficGuiFactoryBC.register("debug.network.stats", false, "Should all network packets be tracked for statistical purposes?", RestartRequirement.NONE);
    reloadConfig(RestartRequirement.GAME);
    wrenchItem = (new ItemWrench()).setTextureLocation("buildcraftcore:wrench").setUnlocalizedName("wrenchItem");
    BCRegistry.INSTANCE.registerItem(wrenchItem, false);
    mapLocationItem = (new ItemMapLocation()).setUnlocalizedName("mapLocation");
    BCRegistry.INSTANCE.registerItem(mapLocationItem, false);
    listItem = (ItemList) (new ItemList()).setUnlocalizedName("list");
    BCRegistry.INSTANCE.registerItem(listItem, false);
    debuggerItem = (new ItemDebugger()).setUnlocalizedName("debugger");
    BCRegistry.INSTANCE.registerItem(debuggerItem, false);
    if (BuildCraftCore.modifyWorld) {
        EnumSpring.WATER.canGen = ConficGuiFactoryBC.get("worldgen.generateWaterSprings").getBoolean();
        springBlock = new BlockSpring();
        springBlock.setUnlocalizedName("eternalSpring");
        BCRegistry.INSTANCE.registerBlock(springBlock, ItemSpring.class, false);
    }
    woodenGearItem = (new ItemBuildCraft()).setTextureLocation("buildcraftcore:gear/wood").setUnlocalizedName("woodenGearItem");
    if (BCRegistry.INSTANCE.registerItem(woodenGearItem, false)) {
        OreDictionary.registerOre("gearWood", new ItemStack(woodenGearItem));
    }
    stoneGearItem = (new ItemBuildCraft()).setTextureLocation("buildcraftcore:gear/stone").setUnlocalizedName("stoneGearItem");
    if (BCRegistry.INSTANCE.registerItem(stoneGearItem, false)) {
        OreDictionary.registerOre("gearStone", new ItemStack(stoneGearItem));
    }
    ironGearItem = (new ItemBuildCraft()).setTextureLocation("buildcraftcore:gear/iron").setUnlocalizedName("ironGearItem");
    if (BCRegistry.INSTANCE.registerItem(ironGearItem, false)) {
        OreDictionary.registerOre("gearIron", new ItemStack(ironGearItem));
    }
    goldGearItem = (new ItemBuildCraft()).setTextureLocation("buildcraftcore:gear/gold").setUnlocalizedName("goldGearItem");
    if (BCRegistry.INSTANCE.registerItem(goldGearItem, false)) {
        OreDictionary.registerOre("gearGold", new ItemStack(goldGearItem));
    }
    diamondGearItem = (new ItemBuildCraft()).setTextureLocation("buildcraftcore:gear/diamond").setUnlocalizedName("diamondGearItem");
    if (BCRegistry.INSTANCE.registerItem(diamondGearItem, false)) {
        OreDictionary.registerOre("gearDiamond", new ItemStack(diamondGearItem));
    }
    paintbrushItem = new ItemPaintbrush();
    paintbrushItem.setUnlocalizedName("paintbrush");
    BCRegistry.INSTANCE.registerItem(paintbrushItem, false);
    if (DEVELOPER_MODE) {
        tabletItem = new ItemTablet();
        tabletItem.setUnlocalizedName("tablet");
        BCRegistry.INSTANCE.registerItem(tabletItem, false);
    }
    decoratedBlock = new BlockDecoration();
    decoratedBlock.setUnlocalizedName("decoratedBlock");
    BCRegistry.INSTANCE.registerBlock(decoratedBlock, true);
    engineBlock = (BlockEngine) CompatHooks.INSTANCE.getBlock(BlockEngine.class);
    BCRegistry.INSTANCE.registerBlock(engineBlock, ItemEngine.class, true);
    engineBlock.registerTile((Class<? extends TileEngineBase>) CompatHooks.INSTANCE.getTile(TileEngineWood.class), 0, "tile.engineWood");
    BCRegistry.INSTANCE.registerTileEntity(TileEngineWood.class, "buildcraft.core.engine.wood", "net.minecraft.src.buildcraft.energy.TileEngineWood");
    markerBlock = (BlockMarker) CompatHooks.INSTANCE.getBlock(BlockMarker.class);
    BCRegistry.INSTANCE.registerBlock(markerBlock.setUnlocalizedName("markerBlock"), false);
    pathMarkerBlock = (BlockPathMarker) CompatHooks.INSTANCE.getBlock(BlockPathMarker.class);
    BCRegistry.INSTANCE.registerBlock(pathMarkerBlock.setUnlocalizedName("pathMarkerBlock"), false);
    MinecraftForge.EVENT_BUS.register(this);
    MinecraftForge.EVENT_BUS.register(new BlockHighlightHandler());
    MinecraftForge.EVENT_BUS.register(new ListTooltipHandler());
    MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE);
    OreDictionary.registerOre("craftingTableWood", Blocks.crafting_table);
}
Also used : BlockHighlightHandler(buildcraft.core.render.BlockHighlightHandler) ItemMapLocation(buildcraft.core.item.ItemMapLocation) ListTooltipHandler(buildcraft.core.list.ListTooltipHandler) Configuration(net.minecraftforge.common.config.Configuration) BlockDecoration(buildcraft.core.block.BlockDecoration) FileConfigManager(buildcraft.lib.config.FileConfigManager) BlockSpring(buildcraft.core.block.BlockSpring) ItemTablet(buildcraft.core.tablet.ItemTablet) SubCommandOp(buildcraft.core.command.SubCommandOp) ItemBuildCraft(buildcraft.core.lib.items.ItemBuildCraft) SubCommandDeop(buildcraft.core.command.SubCommandDeop) ItemStack(net.minecraft.item.ItemStack) File(java.io.File)

Example 2 with FileConfigManager

use of buildcraft.lib.config.FileConfigManager in project BuildCraft by BuildCraft.

the class BCCoreConfig method preInit.

public static void preInit(File cfgFolder) {
    config = new Configuration(new File(cfgFolder, "main.cfg"));
    objConfig = RegistryConfig.setRegistryConfig(BCCore.MODID, new File(cfgFolder, "objects.cfg"));
    BCLibConfig.guiConfigFile = new File(cfgFolder, "gui.json");
    detailedConfigManager = new FileConfigManager(" The buildcraft detailed configuration file. This contains a lot of miscellaneous options that have no " + "affect on gameplay.\n You should refer to the BC source code for a detailed description of what these do. (https://github.com/BuildCraft/BuildCraft)\n" + " This file will be overwritten every time that buildcraft starts, so don't change anything other than the values.");
    detailedConfigManager.setConfigFile(new File(cfgFolder, "detailed.properties"));
    // Variables to make
    String general = Configuration.CATEGORY_GENERAL;
    String display = "display";
    String worldgen = "worldgen";
    String performance = "performance";
    EnumRestartRequirement none = EnumRestartRequirement.NONE;
    EnumRestartRequirement world = EnumRestartRequirement.WORLD;
    EnumRestartRequirement game = EnumRestartRequirement.GAME;
    propColourBlindMode = config.get(display, "colorBlindMode", false);
    propColourBlindMode.setComment("Should I enable colorblind mode?");
    none.setTo(propColourBlindMode);
    propWorldGen = config.get(worldgen, "enable", true);
    propWorldGen.setComment("Should BuildCraft generate anything in the world?");
    game.setTo(propWorldGen);
    propWorldGenWaterSpring = config.get(worldgen, "generateWaterSprings", true);
    propWorldGenWaterSpring.setComment("Should BuildCraft generate water springs?");
    game.setTo(propWorldGenWaterSpring);
    propMinePlayerProtected = config.get(general, "miningBreaksPlayerProtectedBlocks", false);
    propMinePlayerProtected.setComment("Should BuildCraft miners be allowed to break blocks using player-specific protection?");
    none.setTo(propMinePlayerProtected);
    propUseColouredLabels = config.get(display, "useColouredLabels", true);
    propUseColouredLabels.setComment("Should colours be displayed as their own (or a similar) colour in tooltips?");
    none.setTo(propUseColouredLabels);
    propUseHighContrastColouredLabels = config.get(display, "useHighContrastColouredLabels", false);
    propUseHighContrastColouredLabels.setComment("Should colours displayed in tooltips use higher-contrast colours?");
    none.setTo(propUseHighContrastColouredLabels);
    propHidePower = config.get(display, "hidePowerValues", false);
    propHidePower.setComment("Should all power values (MJ, MJ/t) be hidden?");
    none.setTo(propHidePower);
    propHideFluid = config.get(display, "hideFluidValues", false);
    propHideFluid.setComment("Should all fluid values (Buckets, mB, mB/t) be hidden?");
    none.setTo(propHideFluid);
    propUseBucketsStatic = config.get(display, "useBucketsStatic", false);
    propUseBucketsStatic.setComment("Should static fluid values be displayed in terms of buckets rather than thousandths of a bucket? (B vs mB)");
    none.setTo(propUseBucketsStatic);
    propUseBucketsFlow = config.get(display, "useBucketsFlow", false);
    propUseBucketsFlow.setComment("Should flowing fluid values be displayed in terms of buckets per second rather than thousandths of a bucket per tick? (B/s vs mB/t)");
    none.setTo(propUseBucketsFlow);
    propUseLongLocalizedName = config.get(display, "useLongLocalizedName", false);
    propUseLongLocalizedName.setComment("Should localised strings be displayed in long or short form (10 mB / t vs 10 milli buckets per tick");
    none.setTo(propUseLongLocalizedName);
    propDisplayTimeGap = config.get(display, "timeGap", TimeGap.TICKS.name().toLowerCase(Locale.ROOT));
    propDisplayTimeGap.setComment("Should localised strings be displayed in terms of seconds (1 MJ/s) or ticks (20 MJ/t)");
    ConfigUtil.setEnumProperty(propDisplayTimeGap, TimeGap.values());
    none.setTo(propDisplayTimeGap);
    propUseSwappableSprites = config.get(display, "useSwappableSprites", true);
    propUseSwappableSprites.setComment("Disable this if you get texture errors with optifine. Disables some texture switching functionality " + "when changing config options such as colour blind mode.");
    game.setTo(propUseSwappableSprites);
    propEnableAnimatedSprites = config.get(performance, "enableAnimatedSprites", true);
    propEnableAnimatedSprites.setComment("Disable this if you get sub-standard framerates due to buildcraft's ~60 sprites animating every frame.");
    none.setTo(propEnableAnimatedSprites);
    propItemRenderRotation = config.get(display, "itemRenderRotation", RenderRotation.ENABLED.name().toLowerCase(Locale.ROOT));
    propItemRenderRotation.setComment("The rotation that items use when travelling through pipes. Set to 'enabled' for full rotation, " + "'disabled' for no rotation, or 'horizontals_only' to only rotate items when going horizontally.");
    ConfigUtil.setEnumProperty(propItemRenderRotation, RenderRotation.values());
    propChunkLoadLevel = config.get(general, "chunkLoadLevel", ChunkLoaderLevel.SELF_TILES.name().toLowerCase(Locale.ROOT));
    propChunkLoadLevel.setComment("");
    ConfigUtil.setEnumProperty(propChunkLoadLevel, ChunkLoaderLevel.values());
    world.setTo(propChunkLoadLevel);
    propItemLifespan = config.get(general, "itemLifespan", 60);
    propItemLifespan.setMinValue(5).setMaxValue(600);
    propItemLifespan.setComment("How long, in seconds, should items stay on the ground? (Vanilla = 300, default = 60)");
    none.setTo(propItemLifespan);
    propPumpsConsumeWater = config.get(general, "pumpsConsumeWater", false);
    propPumpsConsumeWater.setComment("Should pumps consume water? Enabling this will disable" + " minor optimisations, but work properly with finite water mods.");
    none.setTo(propPumpsConsumeWater);
    propMarkerMaxDistance = config.get(general, "markerMaxDistance", 64);
    propMarkerMaxDistance.setMinValue(16).setMaxValue(256);
    propMarkerMaxDistance.setComment("How far, in minecraft blocks, should markers (volume and path) reach?");
    none.setTo(propMarkerMaxDistance);
    propPumpMaxDistance = config.get(general, "pumpMaxDistance", 64);
    propPumpMaxDistance.setMinValue(16).setMaxValue(128);
    propPumpMaxDistance.setComment("How far, in minecraft blocks, should pumps reach in fluids?");
    none.setTo(propPumpMaxDistance);
    propNetworkUpdateRate = config.get(general, "updateFactor", networkUpdateRate);
    propNetworkUpdateRate.setMinValue(1).setMaxValue(100);
    propNetworkUpdateRate.setComment("How often, in ticks, should network update packets be sent? Increasing this might help network performance.");
    none.setTo(propNetworkUpdateRate);
    reloadConfig(game);
    addReloadListener(BCCoreConfig::reloadConfig);
    MinecraftForge.EVENT_BUS.register(BCCoreConfig.class);
}
Also used : FileConfigManager(buildcraft.lib.config.FileConfigManager) Configuration(net.minecraftforge.common.config.Configuration) EnumRestartRequirement(buildcraft.lib.config.EnumRestartRequirement) File(java.io.File)

Aggregations

FileConfigManager (buildcraft.lib.config.FileConfigManager)2 File (java.io.File)2 Configuration (net.minecraftforge.common.config.Configuration)2 BlockDecoration (buildcraft.core.block.BlockDecoration)1 BlockSpring (buildcraft.core.block.BlockSpring)1 SubCommandDeop (buildcraft.core.command.SubCommandDeop)1 SubCommandOp (buildcraft.core.command.SubCommandOp)1 ItemMapLocation (buildcraft.core.item.ItemMapLocation)1 ItemBuildCraft (buildcraft.core.lib.items.ItemBuildCraft)1 ListTooltipHandler (buildcraft.core.list.ListTooltipHandler)1 BlockHighlightHandler (buildcraft.core.render.BlockHighlightHandler)1 ItemTablet (buildcraft.core.tablet.ItemTablet)1 EnumRestartRequirement (buildcraft.lib.config.EnumRestartRequirement)1 ItemStack (net.minecraft.item.ItemStack)1