Ejemplo n.º 1
0
  public void reloadConfig(ConfigManager.RestartRequirement restartType) {
    if (restartType == ConfigManager.RestartRequirement.GAME) {
      modifyWorld = mainConfigManager.get("worldgen.enable").getBoolean();
      updateFactor = mainConfigManager.get("network.updateFactor").getInt();
      longUpdateFactor = mainConfigManager.get("network.longUpdateFactor").getInt();
      colorBlindMode = mainConfigManager.get("display.colorBlindMode").getBoolean();

      reloadConfig(ConfigManager.RestartRequirement.WORLD);
    } else if (restartType == ConfigManager.RestartRequirement.WORLD) {
      reloadConfig(ConfigManager.RestartRequirement.NONE);
    } else {
      hideFluidNumbers = mainConfigManager.get("display.hideFluidValues").getBoolean();
      hidePowerNumbers = mainConfigManager.get("display.hidePowerValues").getBoolean();
      itemLifespan = mainConfigManager.get("general.itemLifespan").getInt();
      canEnginesExplode = mainConfigManager.get("general.canEnginesExplode").getBoolean();
      consumeWaterSources = mainConfigManager.get("general.pumpsConsumeWater").getBoolean();
      miningMultiplier = (float) mainConfigManager.get("power.miningUsageMultiplier").getDouble();

      if (mainConfigManager.get("general.updateCheck").getBoolean(true)) {
        Version.check();
      }

      if (mainConfiguration.hasChanged()) {
        mainConfiguration.save();
      }
    }
  }
Ejemplo n.º 2
0
  @EventHandler
  public void loadConfiguration(FMLPreInitializationEvent evt) {

    BCLog.initLog();

    mainConfiguration =
        new BuildCraftConfiguration(
            new File(evt.getModConfigurationDirectory(), "buildcraft/main.conf"));
    try {
      mainConfiguration.load();

      Property updateCheck =
          BuildCraftCore.mainConfiguration.get(
              Configuration.CATEGORY_GENERAL, "update.check", true);
      updateCheck.comment = "set to true for version check on startup";
      if (updateCheck.getBoolean(true)) {
        Version.check();
      }

      Property continuousCurrent =
          BuildCraftCore.mainConfiguration.get(
              Configuration.CATEGORY_GENERAL,
              "current.continuous",
              DefaultProps.CURRENT_CONTINUOUS);
      continuousCurrent.comment =
          "set to true for allowing machines to be driven by continuous current";
      continuousCurrentModel = continuousCurrent.getBoolean(DefaultProps.CURRENT_CONTINUOUS);

      Property trackNetwork =
          BuildCraftCore.mainConfiguration.get(
              Configuration.CATEGORY_GENERAL, "trackNetworkUsage", false);
      trackNetworkUsage = trackNetwork.getBoolean(false);

      Property dropBlock =
          BuildCraftCore.mainConfiguration.get(
              Configuration.CATEGORY_GENERAL, "dropBrokenBlocks", true);
      dropBlock.comment = "set to false to prevent fillers from dropping blocks.";
      dropBrokenBlocks = dropBlock.getBoolean(true);

      Property lifespan =
          BuildCraftCore.mainConfiguration.get(
              Configuration.CATEGORY_GENERAL, "itemLifespan", itemLifespan);
      lifespan.comment =
          "the lifespan in ticks of items dropped on the ground by pipes and machines, vanilla = 6000, default = 1200";
      itemLifespan = lifespan.getInt(itemLifespan);
      if (itemLifespan < 100) {
        itemLifespan = 100;
      }

      Property powerFrameworkClass =
          BuildCraftCore.mainConfiguration.get(
              Configuration.CATEGORY_GENERAL,
              "power.framework",
              "buildcraft.energy.PneumaticPowerFramework");

      Property factor =
          BuildCraftCore.mainConfiguration.get(
              Configuration.CATEGORY_GENERAL, "network.updateFactor", 10);
      factor.comment =
          "increasing this number will decrease network update frequency, useful for overloaded servers";
      updateFactor = factor.getInt(10);

      Property longFactor =
          BuildCraftCore.mainConfiguration.get(
              Configuration.CATEGORY_GENERAL, "network.stateRefreshPeriod", 40);
      longFactor.comment =
          "delay between full client sync packets, increasing it saves bandwidth, decreasing makes for better client syncronization.";
      longUpdateFactor = longFactor.getInt(40);

      Property wrenchId =
          BuildCraftCore.mainConfiguration.getItem("wrench.id", DefaultProps.WRENCH_ID);

      wrenchItem =
          (new ItemWrench(wrenchId.getInt(DefaultProps.WRENCH_ID)))
              .setUnlocalizedName("wrenchItem");
      LanguageRegistry.addName(wrenchItem, "Wrench");
      CoreProxy.proxy.registerItem(wrenchItem);

      Property springId =
          BuildCraftCore.mainConfiguration.getBlock("springBlock.id", DefaultProps.SPRING_ID);

      Property woodenGearId =
          BuildCraftCore.mainConfiguration.getItem(
              "woodenGearItem.id", DefaultProps.WOODEN_GEAR_ID);
      Property stoneGearId =
          BuildCraftCore.mainConfiguration.getItem("stoneGearItem.id", DefaultProps.STONE_GEAR_ID);
      Property ironGearId =
          BuildCraftCore.mainConfiguration.getItem("ironGearItem.id", DefaultProps.IRON_GEAR_ID);
      Property goldenGearId =
          BuildCraftCore.mainConfiguration.getItem(
              "goldenGearItem.id", DefaultProps.GOLDEN_GEAR_ID);
      Property diamondGearId =
          BuildCraftCore.mainConfiguration.getItem(
              "diamondGearItem.id", DefaultProps.DIAMOND_GEAR_ID);
      Property modifyWorldProp =
          BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "modifyWorld", true);
      modifyWorldProp.comment =
          "set to false if BuildCraft should not generate custom blocks (e.g. oil)";
      modifyWorld = modifyWorldProp.getBoolean(true);

      Property consumeWater =
          BuildCraftCore.mainConfiguration.get(
              Configuration.CATEGORY_GENERAL, "consumeWater", consumeWaterSources);
      consumeWaterSources = consumeWater.getBoolean(consumeWaterSources);
      consumeWater.comment = "set to true if the Pump should consume water";

      if (BuildCraftCore.modifyWorld) {
        springBlock = new BlockSpring(springId.getInt()).setUnlocalizedName("eternalSpring");
        CoreProxy.proxy.registerBlock(springBlock, ItemSpring.class);
      }

      woodenGearItem =
          (new ItemBuildCraft(woodenGearId.getInt())).setUnlocalizedName("woodenGearItem");
      LanguageRegistry.addName(woodenGearItem, "Wooden Gear");
      CoreProxy.proxy.registerItem(woodenGearItem);
      OreDictionary.registerOre("gearWood", new ItemStack(woodenGearItem));

      stoneGearItem =
          (new ItemBuildCraft(stoneGearId.getInt())).setUnlocalizedName("stoneGearItem");
      LanguageRegistry.addName(stoneGearItem, "Stone Gear");
      CoreProxy.proxy.registerItem(stoneGearItem);
      OreDictionary.registerOre("gearStone", new ItemStack(stoneGearItem));

      ironGearItem = (new ItemBuildCraft(ironGearId.getInt())).setUnlocalizedName("ironGearItem");
      LanguageRegistry.addName(ironGearItem, "Iron Gear");
      CoreProxy.proxy.registerItem(ironGearItem);
      OreDictionary.registerOre("gearIron", new ItemStack(ironGearItem));

      goldGearItem = (new ItemBuildCraft(goldenGearId.getInt())).setUnlocalizedName("goldGearItem");
      LanguageRegistry.addName(goldGearItem, "Gold Gear");
      CoreProxy.proxy.registerItem(goldGearItem);
      OreDictionary.registerOre("gearGold", new ItemStack(goldGearItem));

      diamondGearItem =
          (new ItemBuildCraft(diamondGearId.getInt())).setUnlocalizedName("diamondGearItem");
      LanguageRegistry.addName(diamondGearItem, "Diamond Gear");
      CoreProxy.proxy.registerItem(diamondGearItem);
      OreDictionary.registerOre("gearDiamond", new ItemStack(diamondGearItem));

      Property colorBlindProp =
          BuildCraftCore.mainConfiguration.get(
              Configuration.CATEGORY_GENERAL, "client.colorblindmode", false);
      colorBlindProp.comment = "Set to true to enable alternate textures";
      colorBlindMode = colorBlindProp.getBoolean(false);

      MinecraftForge.EVENT_BUS.register(this);

    } finally {
      if (mainConfiguration.hasChanged()) {
        mainConfiguration.save();
      }
    }
  }