Example #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();
      }
    }
  }
Example #2
0
  @Mod.EventHandler
  public void init(FMLInitializationEvent evt) {
    BuildCraftAPI.proxy = CoreProxy.proxy;

    ChannelHandler coreChannelHandler = new ChannelHandler();
    coreChannelHandler.registerPacketType(PacketTabletMessage.class);

    channels =
        NetworkRegistry.INSTANCE.newChannel(
            DefaultProps.NET_CHANNEL_NAME + "-CORE", coreChannelHandler, new PacketHandlerCore());

    achievementManager = new AchievementManager("BuildCraft");
    FMLCommonHandler.instance().bus().register(achievementManager);

    woodenGearAchievement =
        achievementManager.registerAchievement(
            new Achievement(
                "achievement.woodenGear", "woodenGearAchievement", 0, 0, woodenGearItem, null));
    stoneGearAchievement =
        achievementManager.registerAchievement(
            new Achievement(
                "achievement.stoneGear",
                "stoneGearAchievement",
                2,
                0,
                stoneGearItem,
                woodenGearAchievement));
    ironGearAchievement =
        achievementManager.registerAchievement(
            new Achievement(
                "achievement.ironGear",
                "ironGearAchievement",
                4,
                0,
                ironGearItem,
                stoneGearAchievement));
    goldGearAchievement =
        achievementManager.registerAchievement(
            new Achievement(
                "achievement.goldGear",
                "goldGearAchievement",
                6,
                0,
                goldGearItem,
                ironGearAchievement));
    diamondGearAchievement =
        achievementManager.registerAchievement(
            new Achievement(
                "achievement.diamondGear",
                "diamondGearAchievement",
                8,
                0,
                diamondGearItem,
                goldGearAchievement));
    wrenchAchievement =
        achievementManager.registerAchievement(
            new Achievement(
                "achievement.wrench", "wrenchAchievement", 3, 2, wrenchItem, stoneGearAchievement));
    engineRedstoneAchievement =
        BuildCraftCore.achievementManager.registerAchievement(
            new Achievement(
                "achievement.redstoneEngine",
                "engineAchievement1",
                1,
                -2,
                new ItemStack(engineBlock, 1, 0),
                BuildCraftCore.woodenGearAchievement));

    // BuildCraft 6.1.4 and below - migration only
    StatementManager.registerParameterClass(
        "buildcraft:stackTrigger", StatementParameterItemStack.class);
    StatementManager.registerParameterClass(
        "buildcraft:stackAction", StatementParameterItemStack.class);

    StatementManager.registerParameterClass(StatementParameterItemStack.class);
    StatementManager.registerParameterClass(StatementParameterDirection.class);
    StatementManager.registerParameterClass(StatementParameterRedstoneGateSideOnly.class);
    StatementManager.registerTriggerProvider(new DefaultTriggerProvider());
    StatementManager.registerActionProvider(new DefaultActionProvider());

    if (BuildCraftCore.modifyWorld) {
      MinecraftForge.EVENT_BUS.register(new SpringPopulate());
    }

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

    if (BuildCraftCore.loadDefaultRecipes) {
      loadRecipes();
    }

    BCCreativeTab.get("main").setIcon(new ItemStack(BuildCraftCore.wrenchItem, 1));

    EntityList.stringToClassMapping.remove("BuildCraft|Core.bcLaser");
    EntityList.stringToClassMapping.remove("BuildCraft|Core.bcEnergyLaser");

    BuilderAPI.schematicRegistry.registerSchematicBlock(engineBlock, SchematicEngine.class);

    CoreProxy.proxy.initializeRendering();
    CoreProxy.proxy.initializeEntityRendering();

    NetworkRegistry.INSTANCE.registerGuiHandler(instance, new CoreGuiHandler());

    FMLCommonHandler.instance().bus().register(TabletManagerClient.INSTANCE);
    FMLCommonHandler.instance().bus().register(TabletManagerServer.INSTANCE);
    MinecraftForge.EVENT_BUS.register(TabletManagerClient.INSTANCE);
    MinecraftForge.EVENT_BUS.register(TabletManagerServer.INSTANCE);

    TabletAPI.registerProgram(new TabletProgramMenuFactory());

    // Create filler registry
    try {
      FillerManager.registry = new FillerRegistry();

      // INIT FILLER PATTERNS
      FillerManager.registry.addPattern(PatternFill.INSTANCE);
      FillerManager.registry.addPattern(new PatternFlatten());
      FillerManager.registry.addPattern(new PatternHorizon());
      FillerManager.registry.addPattern(new PatternClear());
      FillerManager.registry.addPattern(new PatternBox());
      FillerManager.registry.addPattern(new PatternPyramid());
      FillerManager.registry.addPattern(new PatternStairs());
      FillerManager.registry.addPattern(new PatternCylinder());
      FillerManager.registry.addPattern(new PatternFrame());
    } catch (Error error) {
      BCLog.logErrorAPI("Buildcraft", error, IFillerPattern.class);
      throw error;
    }

    StatementManager.registerParameterClass(PatternParameterYDir.class);
    StatementManager.registerParameterClass(PatternParameterXZDir.class);
    StatementManager.registerParameterClass(PatternParameterCenter.class);
    StatementManager.registerParameterClass(PatternParameterHollow.class);
  }
Example #3
0
  @Mod.EventHandler
  public void loadConfiguration(FMLPreInitializationEvent evt) {
    BCLog.initLog();

    new BCCreativeTab("main");

    commandBuildcraft.addAlias("bc");
    commandBuildcraft.addChildCommand(new SubCommandVersion());
    commandBuildcraft.addChildCommand(new SubCommandChangelog());

    BuildcraftRecipeRegistry.assemblyTable = AssemblyRecipeManager.INSTANCE;
    BuildcraftRecipeRegistry.integrationTable = IntegrationRecipeManager.INSTANCE;
    BuildcraftRecipeRegistry.refinery = RefineryRecipeManager.INSTANCE;
    BuildcraftRecipeRegistry.programmingTable = ProgrammingRecipeManager.INSTANCE;

    BuilderAPI.schematicRegistry = SchematicRegistry.INSTANCE;

    mainConfiguration =
        new BuildCraftConfiguration(
            new File(evt.getModConfigurationDirectory(), "buildcraft/main.cfg"));
    mainConfigManager = new ConfigManager(mainConfiguration);
    mainConfiguration.load();

    mainConfigManager.getCat("debug").setShowInGui(false);
    mainConfigManager.getCat("vars").setShowInGui(false);

    mainConfigManager.register(
        "general.updateCheck",
        true,
        "Should I check the BuildCraft version on startup?",
        ConfigManager.RestartRequirement.NONE);
    mainConfigManager.register(
        "display.hidePowerValues",
        false,
        "Should all power values (RF, RF/t) be hidden?",
        ConfigManager.RestartRequirement.NONE);
    mainConfigManager.register(
        "display.hideFluidValues",
        false,
        "Should all fluid values (mB, mB/t) be hidden?",
        ConfigManager.RestartRequirement.NONE);
    mainConfigManager
        .register(
            "general.itemLifespan",
            60,
            "How long, in seconds, should items stay on the ground? (Vanilla = 300, default = 60)",
            ConfigManager.RestartRequirement.NONE)
        .setMinValue(5);
    mainConfigManager
        .register(
            "network.updateFactor",
            10,
            "How often, in ticks, should network update packets be sent? Increasing this might help network performance.",
            ConfigManager.RestartRequirement.GAME)
        .setMinValue(1);
    mainConfigManager
        .register(
            "network.longUpdateFactor",
            40,
            "How often, in ticks, should full network sync packets be sent? Increasing this might help network performance.",
            ConfigManager.RestartRequirement.GAME)
        .setMinValue(1);
    mainConfigManager.register(
        "general.canEnginesExplode",
        false,
        "Should engines explode upon overheat?",
        ConfigManager.RestartRequirement.NONE);
    mainConfigManager.register(
        "worldgen.enable",
        true,
        "Should BuildCraft generate anything in the world?",
        ConfigManager.RestartRequirement.GAME);
    mainConfigManager.register(
        "general.pumpsConsumeWater",
        false,
        "Should pumps consume water? Enabling this might cause performance issues!",
        ConfigManager.RestartRequirement.NONE);
    mainConfigManager.register(
        "power.miningUsageMultiplier",
        1.0D,
        "What should the multiplier of all mining-related power usage be?",
        ConfigManager.RestartRequirement.NONE);
    mainConfigManager.register(
        "display.colorBlindMode",
        false,
        "Should I enable colorblind mode?",
        ConfigManager.RestartRequirement.GAME);
    mainConfigManager.register(
        "worldgen.generateWaterSprings",
        true,
        "Should BuildCraft generate water springs?",
        ConfigManager.RestartRequirement.GAME);

    reloadConfig(ConfigManager.RestartRequirement.GAME);

    wrenchItem = (new ItemWrench()).setUnlocalizedName("wrenchItem");
    CoreProxy.proxy.registerItem(wrenchItem);

    mapLocationItem = (new ItemMapLocation()).setUnlocalizedName("mapLocation");
    CoreProxy.proxy.registerItem(mapLocationItem);

    listItem = (ItemList) (new ItemList()).setUnlocalizedName("list");
    CoreProxy.proxy.registerItem(listItem);

    debuggerItem = (new ItemDebugger()).setUnlocalizedName("debugger");
    CoreProxy.proxy.registerItem(debuggerItem);

    if (BuildCraftCore.modifyWorld) {
      BlockSpring.EnumSpring.WATER.canGen =
          BuildCraftCore.mainConfigManager.get("worldgen.generateWaterSprings").getBoolean();
      springBlock = new BlockSpring().setBlockName("eternalSpring");
      CoreProxy.proxy.registerBlock(springBlock, ItemSpring.class);
    }

    woodenGearItem = (new ItemGear()).setUnlocalizedName("woodenGearItem");
    CoreProxy.proxy.registerItem(woodenGearItem);
    OreDictionary.registerOre("gearWood", new ItemStack(woodenGearItem));

    stoneGearItem = (new ItemGear()).setUnlocalizedName("stoneGearItem");
    CoreProxy.proxy.registerItem(stoneGearItem);
    OreDictionary.registerOre("gearStone", new ItemStack(stoneGearItem));

    ironGearItem = (new ItemGear()).setUnlocalizedName("ironGearItem");
    CoreProxy.proxy.registerItem(ironGearItem);
    OreDictionary.registerOre("gearIron", new ItemStack(ironGearItem));

    goldGearItem = (new ItemGear()).setUnlocalizedName("goldGearItem");
    CoreProxy.proxy.registerItem(goldGearItem);
    OreDictionary.registerOre("gearGold", new ItemStack(goldGearItem));

    diamondGearItem = (new ItemGear()).setUnlocalizedName("diamondGearItem");
    CoreProxy.proxy.registerItem(diamondGearItem);
    OreDictionary.registerOre("gearDiamond", new ItemStack(diamondGearItem));

    paintbrushItem = (new ItemPaintbrush()).setUnlocalizedName("paintbrush");
    CoreProxy.proxy.registerItem(paintbrushItem);

    if (TABLET_TESTING) {
      tabletItem = new ItemTablet();
      tabletItem.setUnlocalizedName("tablet");
      CoreProxy.proxy.registerItem(tabletItem);
    }

    buildToolBlock = new BlockBuildTool();
    buildToolBlock.setBlockName("buildToolBlock");
    CoreProxy.proxy.registerBlock(buildToolBlock);

    engineBlock = (BlockEngine) CompatHooks.INSTANCE.getBlock(BlockEngine.class);
    CoreProxy.proxy.registerBlock(engineBlock, ItemEngine.class);
    engineBlock.registerTile(
        (Class<? extends TileEngineBase>) CompatHooks.INSTANCE.getTile(TileEngineWood.class),
        "tile.engineWood");
    CoreProxy.proxy.registerTileEntity(
        TileEngineWood.class, "net.minecraft.src.buildcraft.energy.TileEngineWood");

    FMLCommonHandler.instance().bus().register(this);
    MinecraftForge.EVENT_BUS.register(this);
    MinecraftForge.EVENT_BUS.register(new BlockHighlightHandler());
  }