diff options
Diffstat (limited to 'src/main/java/gregtech/loaders')
-rw-r--r-- | src/main/java/gregtech/loaders/postload/GT_PostLoad.java | 291 | ||||
-rw-r--r-- | src/main/java/gregtech/loaders/preload/GT_PreLoad.java | 527 |
2 files changed, 818 insertions, 0 deletions
diff --git a/src/main/java/gregtech/loaders/postload/GT_PostLoad.java b/src/main/java/gregtech/loaders/postload/GT_PostLoad.java new file mode 100644 index 0000000000..02edca4332 --- /dev/null +++ b/src/main/java/gregtech/loaders/postload/GT_PostLoad.java @@ -0,0 +1,291 @@ +package gregtech.loaders.postload; + +import com.google.common.base.Stopwatch; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ProgressManager; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GT_CLS_Compat; +import gregtech.api.util.GT_Forestry_Compat; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_RecipeRegistrator; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gregtech.common.items.behaviors.Behaviour_DataOrb; +import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Massfabricator; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeOutput; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +import static gregtech.api.enums.GT_Values.MOD_ID_FR; + +@SuppressWarnings("ALL") +public class GT_PostLoad { + public static void activateOreDictHandler() { + Stopwatch stopwatch = Stopwatch.createStarted(); + GT_Mod.gregtechproxy.activateOreDictHandler(); + GT_Mod.GT_FML_LOGGER.info("Congratulations, you have been waiting long enough (" + stopwatch.stop() + "). Have a Cake."); + GT_Log.out.println("GT_Mod: List of Lists of Tool Recipes: " + GT_ModHandler.sSingleNonBlockDamagableRecipeList_list.toString()); + GT_Log.out.println("GT_Mod: Vanilla Recipe List -> Outputs null or stackSize <=0: " + GT_ModHandler.sVanillaRecipeList_warntOutput.toString()); + GT_Log.out.println("GT_Mod: Single Non Block Damagable Recipe List -> Outputs null or stackSize <=0: " + GT_ModHandler.sSingleNonBlockDamagableRecipeList_warntOutput.toString()); + } + + + public static void removeIc2Recipes(Map<IRecipeInput, RecipeOutput> aMaceratorRecipeList, Map<IRecipeInput, RecipeOutput> aCompressorRecipeList, Map<IRecipeInput, RecipeOutput> aExtractorRecipeList, Map<IRecipeInput, RecipeOutput> aOreWashingRecipeList, Map<IRecipeInput, RecipeOutput> aThermalCentrifugeRecipeList) { + Stopwatch stopwatch = Stopwatch.createStarted(); + // remove gemIridium exploit + ItemStack iridiumOre = GT_ModHandler.getIC2Item("iridiumOre", 1); + aCompressorRecipeList.entrySet().parallelStream() + .filter(e -> e.getKey().getInputs().size() == 1 && e.getKey().getInputs().get(0).isItemEqual(iridiumOre)) + .findAny() + .ifPresent(e -> aCompressorRecipeList.remove(e.getKey())); + //Add default IC2 recipe to GT + GT_ModHandler.addIC2RecipesToGT(aMaceratorRecipeList, GT_Recipe.GT_Recipe_Map.sMaceratorRecipes, true, true, true); + GT_ModHandler.addIC2RecipesToGT(aCompressorRecipeList, GT_Recipe.GT_Recipe_Map.sCompressorRecipes, true, true, true); + GT_ModHandler.addIC2RecipesToGT(aExtractorRecipeList, GT_Recipe.GT_Recipe_Map.sExtractorRecipes, true, true, true); + GT_ModHandler.addIC2RecipesToGT(aOreWashingRecipeList, GT_Recipe.GT_Recipe_Map.sOreWasherRecipes, false, true, true); + GT_ModHandler.addIC2RecipesToGT(aThermalCentrifugeRecipeList, GT_Recipe.GT_Recipe_Map.sThermalCentrifugeRecipes, true, true, true); + GT_Mod.GT_FML_LOGGER.info("IC2 Removal (" + stopwatch.stop() + "). Have a Cake."); + } + + + public static void registerFluidCannerRecipes() { + ItemStack ISdata0 = new ItemStack(Items.potionitem, 1, 0); + ItemStack ILdata0 = ItemList.Bottle_Empty.get(1L); + + for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if ((tData.filledContainer.getItem() == Items.potionitem) && (tData.filledContainer.getItemDamage() == 0)) { + GT_Recipe.GT_Recipe_Map.sFluidCannerRecipes.addRecipe(true, new ItemStack[]{ILdata0}, new ItemStack[]{ISdata0}, null, new FluidStack[]{Materials.Water.getFluid(250L)}, null, 4, 1, 0); + GT_Recipe.GT_Recipe_Map.sFluidCannerRecipes.addRecipe(true, new ItemStack[]{ISdata0}, new ItemStack[]{ILdata0}, null, null, null, 4, 1, 0); + } else { + GT_Recipe.GT_Recipe_Map.sFluidCannerRecipes.addRecipe(true, new ItemStack[]{tData.emptyContainer}, new ItemStack[]{tData.filledContainer}, null, new FluidStack[]{tData.fluid}, null, tData.fluid.amount / 62, 1, 0); + GT_Recipe.GT_Recipe_Map.sFluidCannerRecipes.addRecipe(true, new ItemStack[]{tData.filledContainer}, new ItemStack[]{GT_Utility.getContainerItem(tData.filledContainer, true)}, null, null, new FluidStack[]{tData.fluid}, tData.fluid.amount / 62, 1, 0); + } + } + } + + public static void addFakeRecipes() { + GT_Log.out.println("GT_Mod: Adding Fake Recipes for NEI"); + + if (Loader.isModLoaded(MOD_ID_FR)) + GT_Forestry_Compat.populateFakeNeiRecipes(); + + if (ItemList.IC2_Crop_Seeds.get(1L) != null) { + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.IC2_Crop_Seeds.getWildcard(1L)}, new ItemStack[]{ItemList.IC2_Crop_Seeds.getWithName(1L, "Scanned Seeds")}, null, null, null, 160, 8, 0); + } + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{new ItemStack(Items.written_book, 1, 32767)}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Scanned Book Data")}, ItemList.Tool_DataStick.getWithName(1L, "Stick to save it to"), null, null, 128, 30, 0); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{new ItemStack(Items.filled_map, 1, 32767)}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Scanned Map Data")}, ItemList.Tool_DataStick.getWithName(1L, "Stick to save it to"), null, null, 128, 30, 0); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Orb to overwrite")}, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Copy of the Orb")}, ItemList.Tool_DataOrb.getWithName(0L, "Orb to copy"), null, null, 512, 30, 0); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Stick to overwrite")}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Copy of the Stick")}, ItemList.Tool_DataStick.getWithName(0L, "Stick to copy"), null, null, 128, 30, 0); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Raw Prospection Data")}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Analyzed Prospection Data")}, null, null, null, 1000, 30, 0); + if (Loader.isModLoaded("GalacticraftCore")) { + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1, Short.MAX_VALUE).setStackDisplayName("Any Schematic")}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Scanned Schematic")}, ItemList.Tool_DataStick.getWithName(1L, "Stick to save it to"), null, null, 36000, 480, 0); + if (Loader.isModLoaded("GalacticraftMars")) + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1, Short.MAX_VALUE).setStackDisplayName("Any Schematic")}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Scanned Schematic")}, ItemList.Tool_DataStick.getWithName(1L, "Stick to save it to"), null, null, 36000, 480, 0); + if (Loader.isModLoaded("GalaxySpace")) { + for (int i = 4; i < 9; i++) { + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{GT_ModHandler.getModItem("GalaxySpace", "item.SchematicTier" + i, 1).setStackDisplayName("Any Schematic")}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Scanned Schematic")}, ItemList.Tool_DataStick.getWithName(1L, "Stick to save it to"), null, null, 36000, 480, 0); + } + } + } + Materials.getMaterialsMap().values().stream().forEach(tMaterial -> { + if ((tMaterial.mElement != null) && (!tMaterial.mElement.mIsIsotope) && (tMaterial != Materials.Magic) && (tMaterial.getMass() > 0L)) { + ItemStack tOutput = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(tOutput, "Elemental-Scan"); + Behaviour_DataOrb.setDataName(tOutput, tMaterial.mElement.name()); + ItemStack tInput = GT_OreDictUnificator.get(OrePrefixes.dust, tMaterial, 1L); + ItemStack[] ISmat0 = new ItemStack[]{tInput}; + ItemStack[] ISmat1 = new ItemStack[]{tOutput}; + if (tInput != null) { + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, ISmat0, ISmat1, ItemList.Tool_DataOrb.get(1L), null, null, (int) (tMaterial.getMass() * 8192L), 30, 0); + GT_Recipe.GT_Recipe_Map.sReplicatorFakeRecipes.addFakeRecipe(false, null, ISmat0, ISmat1, new FluidStack[]{Materials.UUMatter.getFluid(tMaterial.getMass())}, null, (int) (tMaterial.getMass() * 512L), 30, 0); + + } + tInput = GT_OreDictUnificator.get(OrePrefixes.cell, tMaterial, 1L); + ISmat0 = new ItemStack[]{tInput}; + if (tInput != null) { + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, ISmat0, ISmat1, ItemList.Tool_DataOrb.get(1L), null, null, (int) (tMaterial.getMass() * 8192L), 30, 0); + GT_Recipe.GT_Recipe_Map.sReplicatorFakeRecipes.addFakeRecipe(false, null, ISmat0, ISmat1, new FluidStack[]{Materials.UUMatter.getFluid(tMaterial.getMass())}, null, (int) (tMaterial.getMass() * 512L), 30, 0); + } + } + }); + + if (!GT_MetaTileEntity_Massfabricator.sRequiresUUA) + GT_Recipe.GT_Recipe_Map.sMassFabFakeRecipes.addFakeRecipe(false, null, null, null, null, new FluidStack[]{Materials.UUMatter.getFluid(1L)}, GT_MetaTileEntity_Massfabricator.sDurationMultiplier, 256, 0); + GT_Recipe.GT_Recipe_Map.sMassFabFakeRecipes.addFakeRecipe(false, null, null, null, new FluidStack[]{Materials.UUAmplifier.getFluid(GT_MetaTileEntity_Massfabricator.sUUAperUUM)}, new FluidStack[]{Materials.UUMatter.getFluid(1L)}, GT_MetaTileEntity_Massfabricator.sDurationMultiplier / GT_MetaTileEntity_Massfabricator.sUUASpeedBonus, 256, 0); + GT_Recipe.GT_Recipe_Map.sRockBreakerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.Display_ITS_FREE.getWithName(0L, "Place Lava on Side")}, new ItemStack[]{new ItemStack( + Blocks.cobblestone, 1)}, null, null, null, 16, 30, 0); + GT_Recipe.GT_Recipe_Map.sRockBreakerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.Display_ITS_FREE.getWithName(0L, "Place Lava on Top")}, new ItemStack[]{new ItemStack(Blocks.stone, 1)}, null, null, null, 16, 30, 0); + GT_Recipe.GT_Recipe_Map.sRockBreakerFakeRecipes.addFakeRecipe(false, new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L)}, new ItemStack[]{new ItemStack(Blocks.obsidian, 1)}, null, null, null, 128, 30, 0); + } + + public static void nerfVanillaTools() { + if (GT_Mod.gregtechproxy.mNerfedVanillaTools) { + GT_Log.out.println("GT_Mod: Nerfing Vanilla Tool Durability"); + Items.wooden_sword.setMaxDamage(12); + Items.wooden_pickaxe.setMaxDamage(12); + Items.wooden_shovel.setMaxDamage(12); + Items.wooden_axe.setMaxDamage(12); + Items.wooden_hoe.setMaxDamage(12); + + Items.stone_sword.setMaxDamage(48); + Items.stone_pickaxe.setMaxDamage(48); + Items.stone_shovel.setMaxDamage(48); + Items.stone_axe.setMaxDamage(48); + Items.stone_hoe.setMaxDamage(48); + + Items.iron_sword.setMaxDamage(256); + Items.iron_pickaxe.setMaxDamage(256); + Items.iron_shovel.setMaxDamage(256); + Items.iron_axe.setMaxDamage(256); + Items.iron_hoe.setMaxDamage(256); + + Items.golden_sword.setMaxDamage(24); + Items.golden_pickaxe.setMaxDamage(24); + Items.golden_shovel.setMaxDamage(24); + Items.golden_axe.setMaxDamage(24); + Items.golden_hoe.setMaxDamage(24); + + Items.diamond_sword.setMaxDamage(768); + Items.diamond_pickaxe.setMaxDamage(768); + Items.diamond_shovel.setMaxDamage(768); + Items.diamond_axe.setMaxDamage(768); + Items.diamond_hoe.setMaxDamage(768); + } + } + + public static void replaceVanillaMaterials() { + Stopwatch stopwatch = Stopwatch.createStarted(); + GT_Mod.GT_FML_LOGGER.info("Replacing Vanilla Materials in recipes, please wait."); + Set<Materials> replaceVanillaItemsSet = GT_Mod.gregtechproxy.mUseGreatlyShrukenReplacementList ? Arrays.stream(Materials.values()).filter(GT_RecipeRegistrator::hasVanillaRecipes).collect( + Collectors.toSet()) : new HashSet<>(Arrays.asList(Materials.values())); + + ProgressManager.ProgressBar progressBar = ProgressManager.push("Register materials", replaceVanillaItemsSet.size()); + if (GT_Values.cls_enabled){ + try { + GT_CLS_Compat.doActualRegistrationCLS(progressBar, replaceVanillaItemsSet); + GT_CLS_Compat.pushToDisplayProgress(); + } catch (InvocationTargetException | IllegalAccessException e) { + GT_Mod.GT_FML_LOGGER.catching(e); + } + } + else { + replaceVanillaItemsSet.forEach(m -> { + progressBar.step(m.mDefaultLocalName); + doActualRegistration(m); + }); + } + ProgressManager.pop(progressBar); + GT_Mod.GT_FML_LOGGER.info("Replaced Vanilla Materials (" + stopwatch.stop() + "). Have a Cake."); + } + + public static void doActualRegistration(Materials m){ + String platename = OrePrefixes.plate.get(m).toString(); + boolean noSmash = !m.contains(SubTag.NO_SMASHING); + if ((m.mTypes & 2) != 0) + GT_RecipeRegistrator.registerUsagesForMaterials(platename, noSmash, m.getIngots(1)); + if ((m.mTypes & 4) != 0) + GT_RecipeRegistrator.registerUsagesForMaterials(platename, noSmash, m.getGems(1)); + if (m.getBlocks(1) != null) + GT_RecipeRegistrator.registerUsagesForMaterials(null, noSmash, m.getBlocks(1)); + } + + + public static void createGTtoolsCreativeTab() { + CreativeTabs mainTab = new CreativeTabs("GTtools") { + @SideOnly(Side.CLIENT) + @Override + public ItemStack getIconItemStack() { + return ItemList.Tool_Cheat.get(1, new ItemStack(Blocks.iron_block, 1)); + } + + @SideOnly(Side.CLIENT) + @Override + public Item getTabIconItem() { + return ItemList.Circuit_Integrated.getItem(); + } + + @Override + public void displayAllReleventItems(List aList) { + for (int i = 0; i < 32766; i += 2) { + if (GT_MetaGenerated_Tool_01.INSTANCE.getToolStats(new ItemStack(GT_MetaGenerated_Tool_01.INSTANCE, 1, i)) != null) { + ItemStack tStack = new ItemStack(GT_MetaGenerated_Tool_01.INSTANCE, 1, i); + GT_MetaGenerated_Tool_01.INSTANCE.isItemStackUsable(tStack); + aList.add(GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(i, 1, Materials.Lead, Materials.Lead, null)); + aList.add(GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(i, 1, Materials.Nickel, Materials.Nickel, null)); + aList.add(GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(i, 1, Materials.Cobalt, Materials.Cobalt, null)); + aList.add(GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(i, 1, Materials.Osmium, Materials.Osmium, null)); + aList.add(GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(i, 1, Materials.Adamantium, Materials.Adamantium, null)); + aList.add(GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(i, 1, Materials.Neutronium, Materials.Neutronium, null)); + } + } + super.displayAllReleventItems(aList); + } + }; + } + + public static void addSolidFakeLargeBoilerFuels() { + GT_Recipe.GT_Recipe_Map.sLargeBoilerFakeFuels.addSolidRecipes( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Charcoal, 1), + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 1), + GT_OreDictUnificator.get(OrePrefixes.block, Materials.Charcoal, 1), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Coal, 1), + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 1), + GT_OreDictUnificator.get(OrePrefixes.block, Materials.Coal, 1), + GT_OreDictUnificator.get(OrePrefixes.crushed, Materials.Coal, 1), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lignite, 1), + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Lignite, 1), + GT_OreDictUnificator.get(OrePrefixes.block, Materials.Lignite, 1), + GT_OreDictUnificator.get(OrePrefixes.crushed, Materials.Lignite, 1), + GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 1), + GT_OreDictUnificator.get(OrePrefixes.plank, Materials.Wood, 1), + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.Wood, 1), + GT_OreDictUnificator.get(OrePrefixes.slab, Materials.Wood, 1), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 1), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sodium, 1), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lithium, 1), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Caesium, 1), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sulfur, 1), + GT_OreDictUnificator.get(ItemList.Block_SSFUEL.get(1)), + GT_OreDictUnificator.get(ItemList.Block_MSSFUEL.get(1)), + GT_OreDictUnificator.get(OrePrefixes.rod, Materials.Blaze, 1)); + if (Loader.isModLoaded("Thaumcraft")) { + GT_Recipe.GT_Recipe_Map.sLargeBoilerFakeFuels.addSolidRecipe(GT_ModHandler.getModItem("Thaumcraft", "ItemResource", 1)); + } + } + + public static void identifyAnySteam() { + final String[] steamCandidates = {"steam", "ic2steam"}; + final String[] superHeatedSteamCandidates = {"ic2superheatedsteam"}; + + GT_ModHandler.sAnySteamFluidIDs = Arrays.stream(steamCandidates).map(FluidRegistry::getFluid).filter(Objects::nonNull) + .map(FluidRegistry::getFluidID).collect(Collectors.toList()); + GT_ModHandler.sSuperHeatedSteamFluidIDs = Arrays.stream(superHeatedSteamCandidates).map(FluidRegistry::getFluid).filter(Objects::nonNull) + .map(FluidRegistry::getFluidID).collect(Collectors.toList()); + } +} diff --git a/src/main/java/gregtech/loaders/preload/GT_PreLoad.java b/src/main/java/gregtech/loaders/preload/GT_PreLoad.java new file mode 100644 index 0000000000..15f402e062 --- /dev/null +++ b/src/main/java/gregtech/loaders/preload/GT_PreLoad.java @@ -0,0 +1,527 @@ +package gregtech.loaders.preload; + +import cpw.mods.fml.common.LoadController; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.long_distance.GT_MetaTileEntity_LongDistancePipelineBase; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_Cleanroom; +import net.minecraft.init.Blocks; +import net.minecraftforge.common.config.Configuration; +import org.apache.commons.lang3.StringUtils; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.List; +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static gregtech.GT_Mod.GT_FML_LOGGER; +import static gregtech.api.enums.GT_Values.MOD_ID_AE; + +@SuppressWarnings("ALL") +public class GT_PreLoad { + public static void sortToTheEnd() { + if (GT_Mod.gregtechproxy.mSortToTheEnd) { + try { + GT_FML_LOGGER.info("GT_Mod: Sorting GregTech to the end of the Mod List for further processing."); + LoadController tLoadController = (LoadController) GT_Utility.getFieldContent(Loader.instance(), "modController", true, true); + List<ModContainer> tModList = tLoadController.getActiveModList(); + List<ModContainer> tNewModsList = new ArrayList<>(); + ModContainer tGregTech = null; + short tModList_sS = (short) tModList.size(); + for (short i = 0; i < tModList_sS; i = (short) (i + 1)) { + ModContainer tMod = tModList.get(i); + if (tMod.getModId().equalsIgnoreCase("gregtech")) { + tGregTech = tMod; + } else { + tNewModsList.add(tMod); + } + } + if (tGregTech != null) { + tNewModsList.add(tGregTech); + } + GT_Utility.getField(tLoadController, "activeModList", true, true).set(tLoadController, tNewModsList); + } catch (Throwable e) { + GT_Mod.logStackTrace(e); + } + } + } + + public static void initLocalization(File languageDir) { + GT_FML_LOGGER.info("GT_Mod: Generating Lang-File"); + GT_LanguageManager.sEnglishFile = new Configuration(new File(languageDir, "GregTech.lang")); + GT_LanguageManager.sEnglishFile.load(); + if (GT_LanguageManager.sEnglishFile.get("EnableLangFile", "UseThisFileAsLanguageFile", false).getBoolean(false)) { + GT_LanguageManager.sLanguage = GT_LanguageManager.sEnglishFile.get("EnableLangFile", "Language", "en_US").getString(); + } + + Materials.getMaterialsMap().values().parallelStream().filter( + Objects::nonNull).forEach(aMaterial -> aMaterial.mLocalizedName = GT_LanguageManager.addStringLocalization("Material." + aMaterial.mName.toLowerCase(), aMaterial.mDefaultLocalName)); + } + + public static Configuration getConfiguration(File configDir) { + File tFile = new File(new File(configDir, "GregTech"), "GregTech.cfg"); + Configuration tMainConfig = new Configuration(tFile); + tMainConfig.load(); + tFile = new File(new File(configDir, "GregTech"), "IDs.cfg"); + GT_Config.sConfigFileIDs = new Configuration(tFile); + GT_Config.sConfigFileIDs.load(); + GT_Config.sConfigFileIDs.save(); + GregTech_API.sRecipeFile = new GT_Config(new Configuration(new File(new File(configDir, "GregTech"), "Recipes.cfg"))); + GregTech_API.sMachineFile = new GT_Config(new Configuration(new File(new File(configDir, "GregTech"), "MachineStats.cfg"))); + GregTech_API.sWorldgenFile = new GT_Config(new Configuration(new File(new File(configDir, "GregTech"), "WorldGeneration.cfg"))); + GregTech_API.sMaterialProperties = new GT_Config(new Configuration(new File(new File(configDir, "GregTech"), "MaterialProperties.cfg"))); + GregTech_API.sMaterialComponents = new GT_Config(new Configuration(new File(new File(configDir, "GregTech"), "MaterialComponents.cfg"))); + GregTech_API.sUnification = new GT_Config(new Configuration(new File(new File(configDir, "GregTech"), "Unification.cfg"))); + GregTech_API.sSpecialFile = new GT_Config(new Configuration(new File(new File(configDir, "GregTech"), "Other.cfg"))); + GregTech_API.sOPStuff = new GT_Config(new Configuration(new File(new File(configDir, "GregTech"), "OverpoweredStuff.cfg"))); + + GregTech_API.sClientDataFile = new GT_Config(new Configuration(new File(new File(configDir, "GregTech"), "Client.cfg"))); + return tMainConfig; + } + + public static void initCompat() { + GregTech_API.mIC2Classic = Loader.isModLoaded("IC2-Classic-Spmod"); + GregTech_API.mGTPlusPlus = Loader.isModLoaded("miscutils"); + GregTech_API.mTranslocator = Loader.isModLoaded("Translocator"); + GregTech_API.mTConstruct = Loader.isModLoaded("TConstruct"); + GregTech_API.mGalacticraft = Loader.isModLoaded("GalacticraftCore"); + GregTech_API.mAE2 = Loader.isModLoaded(MOD_ID_AE); + } + + public static void createLogFiles(File parentFile, Configuration tMainConfig) { + GT_Log.mLogFile = new File(parentFile, "logs/GregTech.log"); + if (!GT_Log.mLogFile.exists()) { + try { + GT_Log.mLogFile.createNewFile(); + } catch (Throwable ignored) {} + } + try { + GT_Log.out = GT_Log.err = new PrintStream(GT_Log.mLogFile); + } catch (FileNotFoundException ignored) {} + + if (tMainConfig.get(GT_Mod.aTextGeneral, "LoggingOreDict", false).getBoolean(false)) { + GT_Log.mOreDictLogFile = new File(parentFile, "logs/OreDict.log"); + if (!GT_Log.mOreDictLogFile.exists()) { + try { + GT_Log.mOreDictLogFile.createNewFile(); + } catch (Throwable ignored) {} + } + try { + GT_Log.ore = new PrintStream(GT_Log.mOreDictLogFile); + } catch (Throwable ignored) {} + try { + List<String> tList = ((GT_Log.LogBuffer) GT_Log.ore).mBufferedOreDictLog; + GT_Log.ore.println("******************************************************************************"); + GT_Log.ore.println("* This is the complete log of the GT5-Unofficial OreDictionary Handler. It *"); + GT_Log.ore.println("* processes all OreDictionary entries and can sometimes cause errors. All *"); + GT_Log.ore.println("* entries and errors are being logged. If you see an error please raise an *"); + GT_Log.ore.println("* issue at https://github.com/Blood-Asp/GT5-Unofficial. *"); + GT_Log.ore.println("******************************************************************************"); + tList.forEach(GT_Log.ore::println); + } catch (Throwable ignored) { + } + } + if (tMainConfig.get(GT_Mod.aTextGeneral, "LoggingExplosions", true).getBoolean(true)) { + GT_Log.mExplosionLog = new File(parentFile, "logs/Explosion.log"); + if (!GT_Log.mExplosionLog.exists()) { + try { + GT_Log.mExplosionLog.createNewFile(); + } catch (Throwable ignored) {} + } + try { + GT_Log.exp = new PrintStream(GT_Log.mExplosionLog); + } catch (Throwable ignored) {} + } + + if (tMainConfig.get(GT_Mod.aTextGeneral, "LoggingPlayerActivity", true).getBoolean(true)) { + GT_Log.mPlayerActivityLogFile = new File(parentFile, "logs/PlayerActivity.log"); + if (!GT_Log.mPlayerActivityLogFile.exists()) { + try { + GT_Log.mPlayerActivityLogFile.createNewFile(); + } catch (Throwable ignored) {} + } + try { + GT_Log.pal = new PrintStream(GT_Log.mPlayerActivityLogFile); + } catch (Throwable ignored) {} + } + } + + public static void runMineTweakerCompat() { + if (Loader.isModLoaded("MineTweaker3")) + return; + + GT_FML_LOGGER.info("preReader"); + final List<String> oreTags = new ArrayList<>(); + final File globalDir = new File("scripts"); + if (globalDir.exists()) { + final List<String> scripts = new ArrayList<>(); + for (File file : globalDir.listFiles()) { + if (file.getName().endsWith(".zs")) { + try (BufferedReader br = new BufferedReader(new FileReader(file))) { + String line; + while ((line = br.readLine()) != null) { + scripts.add(line); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + String pattern1 = "<"; + String pattern2 = ">"; + + Pattern p = Pattern.compile(Pattern.quote(pattern1) + "(.*?)" + Pattern.quote(pattern2)); + for (String text : scripts) { + Matcher m = p.matcher(text); + while (m.find()) { + String hit = m.group(1); + if (hit.startsWith("ore:")) { + hit = hit.substring(4); + if (!oreTags.contains(hit)) oreTags.add(hit); + } else if (hit.startsWith("gregtech:gt.metaitem.0")) { + hit = hit.substring(22); + int mIt = Integer.parseInt(hit.substring(0, 1)); + if (mIt > 0) { + int meta = 0; + try { + hit = hit.substring(2); + meta = Integer.parseInt(hit); + } catch (Exception e) { + GT_FML_LOGGER.info("parseError: " + hit); + } + if (meta > 0 && meta < 32000) { + int prefix = meta / 1000; + int material = meta % 1000; + String tag = ""; + String[] tags = new String[]{}; + if (mIt == 1) + tags = new String[]{"dustTiny", "dustSmall", "dust", "dustImpure", "dustPure", "crushed", "crushedPurified", "crushedCentrifuged", "gem", "nugget", null, "ingot", "ingotHot", "ingotDouble", "ingotTriple", "ingotQuadruple", "ingotQuintuple", "plate", "plateDouble", "plateTriple", "plateQuadruple", "plateQuintuple", "plateDense", "stick", "lens", "round", "bolt", "screw", "ring", "foil", "cell", "cellPlasma", "cellMolten"}; + if (mIt == 2) + tags = new String[]{"toolHeadSword", "toolHeadPickaxe", "toolHeadShovel", "toolHeadAxe", "toolHeadHoe", "toolHeadHammer", "toolHeadFile", "toolHeadSaw", "toolHeadDrill", "toolHeadChainsaw", "toolHeadWrench", "toolHeadUniversalSpade", "toolHeadSense", "toolHeadPlow", "toolHeadArrow", "toolHeadBuzzSaw", "turbineBlade", null, null, "wireFine", "gearGtSmall", "rotor", "stickLong", "springSmall", "spring", "arrowGtWood", "arrowGtPlastic", "gemChipped", "gemFlawed", "gemFlawless", "gemExquisite", "gearGt"}; + if (mIt == 3) + tags = new String[]{"crateGtDust", "crateGtIngot", "crateGtGem", "crateGtPlate", "itemCasing"}; + if (tags.length > prefix) tag = tags[prefix]; + if (GregTech_API.sGeneratedMaterials[material] != null) { + tag += GregTech_API.sGeneratedMaterials[material].mName; + if (!oreTags.contains(tag)) oreTags.add(tag); + } else if (material > 0) { + GT_FML_LOGGER.info("MaterialDisabled: " + material + " " + m.group(1)); + } + } + } + } + } + } + } + + final String[] preS = new String[]{"dustTiny", "dustSmall", "dust", "dustImpure", "dustPure", "crushed", "crushedPurified", "crushedCentrifuged", "gem", "nugget", "ingot", "ingotHot", "ingotDouble", "ingotTriple", "ingotQuadruple", "ingotQuintuple", "plate", "plateDouble", "plateTriple", "plateQuadruple", "plateQuintuple", "plateDense", "stick", "lens", "round", "bolt", "screw", "ring", "foil", "cell", "cellPlasma", "toolHeadSword", "toolHeadPickaxe", "toolHeadShovel", "toolHeadAxe", "toolHeadHoe", "toolHeadHammer", "toolHeadFile", "toolHeadSaw", "toolHeadDrill", "toolHeadChainsaw", "toolHeadWrench", "toolHeadUniversalSpade", "toolHeadSense", "toolHeadPlow", "toolHeadArrow", "toolHeadBuzzSaw", "turbineBlade", "wireFine", "gearGtSmall", "rotor", "stickLong", "springSmall", "spring", "arrowGtWood", "arrowGtPlastic", "gemChipped", "gemFlawed", "gemFlawless", "gemExquisite", "gearGt", "crateGtDust", "crateGtIngot", "crateGtGem", "crateGtPlate", "cellMolten"}; + + List<String> mMTTags = new ArrayList<>(); + oreTags.stream() + .filter(test -> StringUtils.startsWithAny(test, preS)) + .forEach(test -> { + mMTTags.add(test); + if (GT_Values.D1) + GT_FML_LOGGER.info("oretag: " + test); + }); + + GT_FML_LOGGER.info("reenableMetaItems"); + + for (String reEnable : mMTTags) { + OrePrefixes tPrefix = OrePrefixes.getOrePrefix(reEnable); + if (tPrefix != null) { + Materials tName = Materials.get(reEnable.replaceFirst(tPrefix.toString(), "")); + if (tName != null) { + tPrefix.mDisabledItems.remove(tName); + tPrefix.mGeneratedItems.add(tName); + if (tPrefix == OrePrefixes.screw) { + OrePrefixes.bolt.mDisabledItems.remove(tName); + OrePrefixes.bolt.mGeneratedItems.add(tName); + OrePrefixes.stick.mDisabledItems.remove(tName); + OrePrefixes.stick.mGeneratedItems.add(tName); + } + if (tPrefix == OrePrefixes.round) { + OrePrefixes.nugget.mDisabledItems.remove(tName); + OrePrefixes.nugget.mGeneratedItems.add(tName); + } + if (tPrefix == OrePrefixes.spring) { + OrePrefixes.stickLong.mDisabledItems.remove(tName); + OrePrefixes.stickLong.mGeneratedItems.add(tName); + OrePrefixes.stick.mDisabledItems.remove(tName); + OrePrefixes.stick.mGeneratedItems.add(tName); + } + if (tPrefix == OrePrefixes.springSmall) { + OrePrefixes.stick.mDisabledItems.remove(tName); + OrePrefixes.stick.mGeneratedItems.add(tName); + } + if (tPrefix == OrePrefixes.stickLong) { + OrePrefixes.stick.mDisabledItems.remove(tName); + OrePrefixes.stick.mGeneratedItems.add(tName); + } + if (tPrefix == OrePrefixes.rotor) { + OrePrefixes.ring.mDisabledItems.remove(tName); + OrePrefixes.ring.mGeneratedItems.add(tName); + } + } else { + GT_FML_LOGGER.info("noMaterial " + reEnable); + } + } else { + GT_FML_LOGGER.info("noPrefix " + reEnable); + } + } + } + + public static void adjustScrap() { + GT_FML_LOGGER.info("GT_Mod: Removing all original Scrapbox Drops."); + try { + GT_Utility.getField("ic2.core.item.ItemScrapbox$Drop", "topChance", true, true).set(null, 0); + ((List) GT_Utility.getFieldContent(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "drops", true, true)).clear(); + } catch (Throwable e) { + if (GT_Values.D1) { + e.printStackTrace(GT_Log.err); + } + } + GT_Log.out.println("GT_Mod: Adding Scrap with a Weight of 200.0F to the Scrapbox Drops."); + GT_ModHandler.addScrapboxDrop(200.0F, GT_ModHandler.getIC2Item("scrap", 1L)); + } + + public static void loadConfig(Configuration tMainConfig) { + GT_Values.D1 = tMainConfig.get(GT_Mod.aTextGeneral, "Debug", false).getBoolean(false); + GT_Values.D2 = tMainConfig.get(GT_Mod.aTextGeneral, "Debug2", false).getBoolean(false); + GT_Values.hideAssLineRecipes = tMainConfig.get(GT_Mod.aTextGeneral, "hide assline recipes", false).getBoolean(false); + GT_Values.updateFluidDisplayItems = tMainConfig.get(GT_Mod.aTextGeneral, "update fluid display items", true).getBoolean(true); + GT_Values.allow_broken_recipemap = tMainConfig.get(GT_Mod.aTextGeneral, "debug allow broken recipemap", false).getBoolean(false); + GT_Values.debugCleanroom = tMainConfig.get(GT_Mod.aTextGeneral, "debugCleanroom", false).getBoolean(false); + GT_Values.debugDriller = tMainConfig.get(GT_Mod.aTextGeneral, "debugDriller", false).getBoolean(false); + GT_Values.debugWorldGen = tMainConfig.get(GT_Mod.aTextGeneral, "debugWorldGen", false).getBoolean(false); + GT_Values.debugOrevein = tMainConfig.get(GT_Mod.aTextGeneral, "debugOrevein", false).getBoolean(false); + GT_Values.debugSmallOres = tMainConfig.get(GT_Mod.aTextGeneral, "debugSmallOres", false).getBoolean(false); + GT_Values.debugStones = tMainConfig.get(GT_Mod.aTextGeneral, "debugStones", false).getBoolean(false); + GT_Values.debugBlockMiner = tMainConfig.get(GT_Mod.aTextGeneral, "debugBlockMiner", false).getBoolean(false); + GT_Values.debugBlockPump = tMainConfig.get(GT_Mod.aTextGeneral, "debugBlockPump", false).getBoolean(false); + GT_Values.debugEntityCramming = tMainConfig.get(GT_Mod.aTextGeneral, "debugEntityCramming", false).getBoolean(false); + GT_Values.debugWorldData = tMainConfig.get(GT_Mod.aTextGeneral, "debugWorldData", false).getBoolean(false); + GT_Values.oreveinPercentage = tMainConfig.get(GT_Mod.aTextGeneral, "oreveinPercentage_100", 100).getInt(100); + GT_Values.oreveinAttempts = tMainConfig.get(GT_Mod.aTextGeneral, "oreveinAttempts_64", 64).getInt(64); + GT_Values.oreveinMaxPlacementAttempts = tMainConfig.get(GT_Mod.aTextGeneral, "oreveinMaxPlacementAttempts_8", 8).getInt(8); + GT_Values.oreveinPlacerOres = tMainConfig.get(GT_Mod.aTextGeneral, "oreveinPlacerOres", true).getBoolean(true); + GT_Values.oreveinPlacerOresMultiplier = tMainConfig.get(GT_Mod.aTextGeneral, "oreveinPlacerOresMultiplier", 2).getInt(2); + //GT_Values.oreveinMaxSize = tMainConfig.get(aTextGeneral, "oreveinMaxSize_64",64).getInt(64); + GT_Values.ticksBetweenSounds = tMainConfig.get("machines", "TicksBetweenSounds", 30).getInt(30); + GT_Values.cleanroomGlass = (float) tMainConfig.get("machines", "ReinforcedGlassPercentageForCleanroom", 5D).getDouble(5D); + GT_Values.enableChunkloaders = tMainConfig.get("machines", "enableChunkloaders", true).getBoolean(true); + GT_Values.alwaysReloadChunkloaders = tMainConfig.get("machines", "alwaysReloadChunkloaders", false).getBoolean(false); + GT_Values.debugChunkloaders = tMainConfig.get("machines", "debugChunkloaders", false).getBoolean(false); + GT_Values.disableDigitalChestsExternalAccess = tMainConfig.get("machines", "disableDigitalChestsExternalAccess", false).getBoolean(false); + GregTech_API.TICKS_FOR_LAG_AVERAGING = tMainConfig.get(GT_Mod.aTextGeneral, "TicksForLagAveragingWithScanner", 25).getInt(25); + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING = tMainConfig.get(GT_Mod.aTextGeneral, "MillisecondsPassedInGTTileEntityUntilLagWarning", 100).getInt(100); + if (tMainConfig.get(GT_Mod.aTextGeneral, "disable_STDOUT", false).getBoolean(false)) { + GT_FML_LOGGER.info("Disableing Console Messages."); + GT_FML_LOGGER.exit(); + System.out.close(); + System.err.close(); + } + /*if (tMainConfig.get(aTextGeneral, "disable_STDERR", false).getBoolean(false)) { + System.err.close(); + }*/ + GregTech_API.sMachineExplosions = tMainConfig.get("machines", "machines_explosion_damage", true).getBoolean(false); + GregTech_API.sMachineFlammable = tMainConfig.get("machines", "machines_flammable", true).getBoolean(false); + GregTech_API.sMachineNonWrenchExplosions = tMainConfig.get("machines", "explosions_on_nonwrenching", true).getBoolean(false); + GregTech_API.sMachineWireFire = tMainConfig.get("machines", "wirefire_on_explosion", true).getBoolean(false); + GregTech_API.sMachineFireExplosions = tMainConfig.get("machines", "fire_causes_explosions", true).getBoolean(false); + GregTech_API.sMachineRainExplosions = tMainConfig.get("machines", "rain_causes_explosions", true).getBoolean(false); + GregTech_API.sMachineThunderExplosions = tMainConfig.get("machines", "lightning_causes_explosions", true).getBoolean(false); + GregTech_API.sConstantEnergy = tMainConfig.get("machines", "constant_need_of_energy", true).getBoolean(false); + GregTech_API.sColoredGUI = tMainConfig.get("machines", "colored_guis_when_painted", true).getBoolean(false); + GregTech_API.sMachineMetalGUI = tMainConfig.get("machines", "guis_in_consistent_machine_metal_color", false).getBoolean(false); + + // Implementation for this is actually handled in NewHorizonsCoreMod in MainRegistry.java! + GregTech_API.sUseMachineMetal = tMainConfig.get("machines", "use_machine_metal_tint", true).getBoolean(true); + + GregTech_API.sTimber = tMainConfig.get(GT_Mod.aTextGeneral, "timber_axe", true).getBoolean(true); + GregTech_API.sDrinksAlwaysDrinkable = tMainConfig.get(GT_Mod.aTextGeneral, "drinks_always_drinkable", false).getBoolean(false); + GregTech_API.sDoShowAllItemsInCreative = tMainConfig.get(GT_Mod.aTextGeneral, "show_all_metaitems_in_creative_and_NEI", false).getBoolean(false); + GregTech_API.sMultiThreadedSounds = tMainConfig.get(GT_Mod.aTextGeneral, "sound_multi_threading", false).getBoolean(false); + String SBdye0 = "ColorModulation."; + Arrays.stream(Dyes.values()).filter(tDye -> (tDye != Dyes._NULL) && (tDye.mIndex < 0)).forEach(tDye -> { + String SBdye1 = SBdye0 + tDye; + tDye.mRGBa[0] = ((short) Math.min(255, Math.max(0, GregTech_API.sClientDataFile.get(SBdye1, "R", tDye.mRGBa[0])))); + tDye.mRGBa[1] = ((short) Math.min(255, Math.max(0, GregTech_API.sClientDataFile.get(SBdye1, "G", tDye.mRGBa[1])))); + tDye.mRGBa[2] = ((short) Math.min(255, Math.max(0, GregTech_API.sClientDataFile.get(SBdye1, "B", tDye.mRGBa[2])))); + } + ); + GT_Mod.gregtechproxy.mRenderTileAmbientOcclusion = GregTech_API.sClientDataFile.get("render", "TileAmbientOcclusion", true); + GT_Mod.gregtechproxy.mRenderGlowTextures = GregTech_API.sClientDataFile.get("render", "GlowTextures", true); + GT_Mod.gregtechproxy.mRenderFlippedMachinesFlipped = GregTech_API.sClientDataFile.get("render", "RenderFlippedMachinesFlipped", true); + GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch = GregTech_API.sClientDataFile.get("render", "RenderIndicatorsOnHatch", true); + GT_Mod.gregtechproxy.mRenderDirtParticles = GregTech_API.sClientDataFile.get("render", "RenderDirtParticles", true); + GT_Mod.gregtechproxy.mRenderPollutionFog = GregTech_API.sClientDataFile.get("render", "RenderPollutionFog", true); + + GT_Mod.gregtechproxy.mMaxEqualEntitiesAtOneSpot = tMainConfig.get(GT_Mod.aTextGeneral, "MaxEqualEntitiesAtOneSpot", 3).getInt(3); + GT_Mod.gregtechproxy.mSkeletonsShootGTArrows = tMainConfig.get(GT_Mod.aTextGeneral, "SkeletonsShootGTArrows", 16).getInt(16); + GT_Mod.gregtechproxy.mFlintChance = tMainConfig.get(GT_Mod.aTextGeneral, "FlintAndSteelChance", 30).getInt(30); + GT_Mod.gregtechproxy.mItemDespawnTime = tMainConfig.get(GT_Mod.aTextGeneral, "ItemDespawnTime", 6000).getInt(6000); + GT_Mod.gregtechproxy.mAllowSmallBoilerAutomation = tMainConfig.get(GT_Mod.aTextGeneral, "AllowSmallBoilerAutomation", false).getBoolean(false); + GT_Mod.gregtechproxy.mHardMachineCasings = tMainConfig.get(GT_Mod.aTextGeneral, "HardMachineCasings", true).getBoolean(true); + GT_Mod.gregtechproxy.mDisableVanillaOres = tMainConfig.get(GT_Mod.aTextGeneral, "DisableVanillaOres", true).getBoolean(true); + GT_Mod.gregtechproxy.mNerfDustCrafting = tMainConfig.get(GT_Mod.aTextGeneral, "NerfDustCrafting", true).getBoolean(true); + GT_Mod.gregtechproxy.mIncreaseDungeonLoot = tMainConfig.get(GT_Mod.aTextGeneral, "IncreaseDungeonLoot", true).getBoolean(true); + GT_Mod.gregtechproxy.mAxeWhenAdventure = tMainConfig.get(GT_Mod.aTextGeneral, "AdventureModeStartingAxe", true).getBoolean(true); + GT_Mod.gregtechproxy.mHardcoreCables = tMainConfig.get(GT_Mod.aTextGeneral, "HardCoreCableLoss", false).getBoolean(false); + GT_Mod.gregtechproxy.mSurvivalIntoAdventure = tMainConfig.get(GT_Mod.aTextGeneral, "forceAdventureMode", false).getBoolean(false); + GT_Mod.gregtechproxy.mHungerEffect = tMainConfig.get(GT_Mod.aTextGeneral, "AFK_Hunger", false).getBoolean(false); + GT_Mod.gregtechproxy.mHardRock = tMainConfig.get(GT_Mod.aTextGeneral, "harderstone", false).getBoolean(false); + GT_Mod.gregtechproxy.mInventoryUnification = tMainConfig.get(GT_Mod.aTextGeneral, "InventoryUnification", true).getBoolean(true); + GT_Mod.gregtechproxy.mGTBees = tMainConfig.get(GT_Mod.aTextGeneral, "GTBees", true).getBoolean(true); + GT_Mod.gregtechproxy.mCraftingUnification = tMainConfig.get(GT_Mod.aTextGeneral, "CraftingUnification", true).getBoolean(true); + GT_Mod.gregtechproxy.mNerfedWoodPlank = tMainConfig.get(GT_Mod.aTextGeneral, "WoodNeedsSawForCrafting", true).getBoolean(true); + GT_Mod.gregtechproxy.mNerfedVanillaTools = tMainConfig.get(GT_Mod.aTextGeneral, "smallerVanillaToolDurability", true).getBoolean(true); + GT_Mod.gregtechproxy.mSortToTheEnd = tMainConfig.get(GT_Mod.aTextGeneral, "EnsureToBeLoadedLast", true).getBoolean(true); + GT_Mod.gregtechproxy.mDisableIC2Cables = tMainConfig.get(GT_Mod.aTextGeneral, "DisableIC2Cables", true).getBoolean(true); + GT_Mod.gregtechproxy.mAchievements = tMainConfig.get(GT_Mod.aTextGeneral, "EnableAchievements", true).getBoolean(true); + GT_Mod.gregtechproxy.mAE2Integration = GregTech_API.sSpecialFile.get(ConfigCategories.general, "EnableAE2Integration", GregTech_API.mAE2); + GT_Mod.gregtechproxy.mNerfedCombs = tMainConfig.get(GT_Mod.aTextGeneral, "NerfCombs", true).getBoolean(true); + GT_Mod.gregtechproxy.mNerfedCrops = tMainConfig.get(GT_Mod.aTextGeneral, "NerfCrops", true).getBoolean(true); + GT_Mod.gregtechproxy.mHideUnusedOres = tMainConfig.get(GT_Mod.aTextGeneral, "HideUnusedOres", true).getBoolean(true); + GT_Mod.gregtechproxy.mHideRecyclingRecipes = tMainConfig.get(GT_Mod.aTextGeneral, "HideRecyclingRecipes", true).getBoolean(true); + GT_Mod.gregtechproxy.mArcSmeltIntoAnnealed = tMainConfig.get(GT_Mod.aTextGeneral, "ArcSmeltIntoAnnealedWrought", true).getBoolean(true); + GT_Mod.gregtechproxy.mEnableAllMaterials = tMainConfig.get("general", "EnableAllMaterials", false).getBoolean(false); + GT_Mod.gregtechproxy.mEnableAllComponents = tMainConfig.get("general", "EnableAllComponents", false).getBoolean(false); + + //Pollution: edit GT_Proxy.java to change default values + GT_Mod.gregtechproxy.mPollution = tMainConfig.get("Pollution", "EnablePollution", GT_Mod.gregtechproxy.mPollution).getBoolean( + GT_Mod.gregtechproxy.mPollution); + GT_Mod.gregtechproxy.mPollutionSmogLimit = tMainConfig.get("Pollution", "SmogLimit", GT_Mod.gregtechproxy.mPollutionSmogLimit).getInt( + GT_Mod.gregtechproxy.mPollutionSmogLimit); + GT_Mod.gregtechproxy.mPollutionPoisonLimit = tMainConfig.get("Pollution", "PoisonLimit", GT_Mod.gregtechproxy.mPollutionPoisonLimit).getInt( + GT_Mod.gregtechproxy.mPollutionPoisonLimit); + GT_Mod.gregtechproxy.mPollutionVegetationLimit = tMainConfig.get("Pollution", "VegetationLimit", GT_Mod.gregtechproxy.mPollutionVegetationLimit).getInt( + GT_Mod.gregtechproxy.mPollutionVegetationLimit); + GT_Mod.gregtechproxy.mPollutionSourRainLimit = tMainConfig.get("Pollution", "SourRainLimit", GT_Mod.gregtechproxy.mPollutionSourRainLimit).getInt( + GT_Mod.gregtechproxy.mPollutionSourRainLimit); + GT_Mod.gregtechproxy.mPollutionOnExplosion = tMainConfig.get("Pollution", "SourRainLimit", GT_Mod.gregtechproxy.mPollutionOnExplosion).getInt( + GT_Mod.gregtechproxy.mPollutionOnExplosion); + GT_Mod.gregtechproxy.mExplosionItemDrop = tMainConfig.get("general", "ExplosionItemDrops", GT_Mod.gregtechproxy.mExplosionItemDrop).getBoolean( + GT_Mod.gregtechproxy.mExplosionItemDrop); + GT_Mod.gregtechproxy.mPollutionPrimitveBlastFurnacePerSecond = tMainConfig.get("Pollution", "PollutionPrimitiveBlastFurnace", GT_Mod.gregtechproxy.mPollutionPrimitveBlastFurnacePerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionPrimitveBlastFurnacePerSecond); + GT_Mod.gregtechproxy.mPollutionCharcoalPitPerSecond = tMainConfig.get("Pollution", "PollutionCharcoalPit", GT_Mod.gregtechproxy.mPollutionCharcoalPitPerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionCharcoalPitPerSecond); + GT_Mod.gregtechproxy.mPollutionEBFPerSecond = tMainConfig.get("Pollution", "PollutionEBF", GT_Mod.gregtechproxy.mPollutionEBFPerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionEBFPerSecond); + GT_Mod.gregtechproxy.mPollutionLargeCombustionEnginePerSecond = tMainConfig.get("Pollution", "PollutionLargeCombustionEngine", GT_Mod.gregtechproxy.mPollutionLargeCombustionEnginePerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionLargeCombustionEnginePerSecond); + GT_Mod.gregtechproxy.mPollutionExtremeCombustionEnginePerSecond = tMainConfig.get("Pollution", "PollutionExtremeCombustionEngine", GT_Mod.gregtechproxy.mPollutionExtremeCombustionEnginePerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionExtremeCombustionEnginePerSecond); + GT_Mod.gregtechproxy.mPollutionImplosionCompressorPerSecond = tMainConfig.get("Pollution", "PollutionImplosionCompressor", GT_Mod.gregtechproxy.mPollutionImplosionCompressorPerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionImplosionCompressorPerSecond); + GT_Mod.gregtechproxy.mPollutionLargeBronzeBoilerPerSecond = tMainConfig.get("Pollution", "PollutionLargeBronzeBoiler", GT_Mod.gregtechproxy.mPollutionLargeBronzeBoilerPerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionLargeBronzeBoilerPerSecond); + GT_Mod.gregtechproxy.mPollutionLargeSteelBoilerPerSecond = tMainConfig.get("Pollution", "PollutionLargeSteelBoiler", GT_Mod.gregtechproxy.mPollutionLargeSteelBoilerPerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionLargeSteelBoilerPerSecond); + GT_Mod.gregtechproxy.mPollutionLargeTitaniumBoilerPerSecond = tMainConfig.get("Pollution", "PollutionLargeTitaniumBoiler", GT_Mod.gregtechproxy.mPollutionLargeTitaniumBoilerPerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionLargeTitaniumBoilerPerSecond); + GT_Mod.gregtechproxy.mPollutionLargeTungstenSteelBoilerPerSecond = tMainConfig.get("Pollution", "PollutionLargeTungstenSteelBoiler", GT_Mod.gregtechproxy.mPollutionLargeTungstenSteelBoilerPerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionLargeTungstenSteelBoilerPerSecond); + GT_Mod.gregtechproxy.mPollutionReleasedByThrottle = tMainConfig.get("Pollution", "PollutionReleasedByThrottle", GT_Mod.gregtechproxy.mPollutionReleasedByThrottle).getDouble( + GT_Mod.gregtechproxy.mPollutionReleasedByThrottle); + GT_Mod.gregtechproxy.mPollutionLargeGasTurbinePerSecond = tMainConfig.get("Pollution", "PollutionLargeGasTurbine", GT_Mod.gregtechproxy.mPollutionLargeGasTurbinePerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionLargeGasTurbinePerSecond); + GT_Mod.gregtechproxy.mPollutionMultiSmelterPerSecond = tMainConfig.get("Pollution", "PollutionMultiSmelter", GT_Mod.gregtechproxy.mPollutionMultiSmelterPerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionMultiSmelterPerSecond); + GT_Mod.gregtechproxy.mPollutionPyrolyseOvenPerSecond = tMainConfig.get("Pollution", "PollutionPyrolyseOven", GT_Mod.gregtechproxy.mPollutionPyrolyseOvenPerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionPyrolyseOvenPerSecond); + GT_Mod.gregtechproxy.mPollutionSmallCoalBoilerPerSecond = tMainConfig.get("Pollution", "PollutionSmallCoalBoiler", GT_Mod.gregtechproxy.mPollutionSmallCoalBoilerPerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionSmallCoalBoilerPerSecond); + GT_Mod.gregtechproxy.mPollutionHighPressureLavaBoilerPerSecond = tMainConfig.get("Pollution", "PollutionHighPressureLavaBoiler", GT_Mod.gregtechproxy.mPollutionHighPressureLavaBoilerPerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionHighPressureLavaBoilerPerSecond); + GT_Mod.gregtechproxy.mPollutionHighPressureCoalBoilerPerSecond = tMainConfig.get("Pollution", "PollutionHighPressureCoalBoiler", GT_Mod.gregtechproxy.mPollutionHighPressureCoalBoilerPerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionHighPressureCoalBoilerPerSecond); + GT_Mod.gregtechproxy.mPollutionBaseDieselGeneratorPerSecond = tMainConfig.get("Pollution", "PollutionBaseDieselGenerator", GT_Mod.gregtechproxy.mPollutionBaseDieselGeneratorPerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionBaseDieselGeneratorPerSecond); + GT_Mod.gregtechproxy.mPollutionDieselGeneratorReleasedByTier = tMainConfig.get("Pollution", "PollutionReleasedByTierDieselGenerator", GT_Mod.gregtechproxy.mPollutionDieselGeneratorReleasedByTier).getDoubleList(); + GT_Mod.gregtechproxy.mPollutionBaseGasTurbinePerSecond = tMainConfig.get("Pollution", "PollutionBaseGasTurbineGenerator", GT_Mod.gregtechproxy.mPollutionBaseGasTurbinePerSecond).getInt( + GT_Mod.gregtechproxy.mPollutionBaseGasTurbinePerSecond); + GT_Mod.gregtechproxy.mPollutionGasTurbineReleasedByTier = tMainConfig.get("Pollution", "PollutionReleasedByTierGasTurbineGenerator", GT_Mod.gregtechproxy.mPollutionGasTurbineReleasedByTier).getDoubleList(); + + GT_Mod.gregtechproxy.mUndergroundOil.getConfig(tMainConfig, "undergroundfluid"); + GT_Mod.gregtechproxy.mEnableCleanroom = tMainConfig.get("general", "EnableCleanroom", true).getBoolean(true); + if (GT_Mod.gregtechproxy.mEnableCleanroom) + GT_MetaTileEntity_Cleanroom.loadConfig(tMainConfig); + GT_Mod.gregtechproxy.mLowGravProcessing = Loader.isModLoaded(GT_Values.MOD_ID_GC_CORE) && tMainConfig.get("general", "LowGravProcessing", true).getBoolean(true); + GT_Mod.gregtechproxy.mUseGreatlyShrukenReplacementList = tMainConfig.get("general", "GTNH Optimised Material Loading", true).getBoolean(true); + Calendar now = Calendar.getInstance(); + GT_Mod.gregtechproxy.mAprilFool = GregTech_API.sSpecialFile.get(ConfigCategories.general, "AprilFool", now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) == 1); + GT_Mod.gregtechproxy.mCropNeedBlock = tMainConfig.get("general", "CropNeedBlockBelow", true).getBoolean(true); + GT_Mod.gregtechproxy.mDisableOldChemicalRecipes = tMainConfig.get("general", "DisableOldChemicalRecipes", false).getBoolean(false); + GT_Mod.gregtechproxy.mAMHInteraction = tMainConfig.get("general", "AllowAutoMaintenanceHatchInteraction", false).getBoolean(false); + GregTech_API.mOutputRF = GregTech_API.sOPStuff.get(ConfigCategories.general, "OutputRF", true); + GregTech_API.mInputRF = GregTech_API.sOPStuff.get(ConfigCategories.general, "InputRF", false); + GregTech_API.mEUtoRF = GregTech_API.sOPStuff.get(ConfigCategories.general, "100EUtoRF", 360); + GregTech_API.mRFtoEU = GregTech_API.sOPStuff.get(ConfigCategories.general, "100RFtoEU", 20); + GregTech_API.mRFExplosions = GregTech_API.sOPStuff.get(ConfigCategories.general, "RFExplosions", false); + GregTech_API.meIOLoaded = Loader.isModLoaded("EnderIO"); + GT_Mod.gregtechproxy.mForceFreeFace = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "forceFreeFace", true); + GT_Mod.gregtechproxy.mBrickedBlastFurnace = tMainConfig.get("general", "BrickedBlastFurnace", true).getBoolean(true); + GT_Mod.gregtechproxy.mEasierIVPlusCables = tMainConfig.get("general", "EasierEVPlusCables", false).getBoolean(false); + GT_Mod.gregtechproxy.mMixedOreOnlyYieldsTwoThirdsOfPureOre = tMainConfig.get("general", "MixedOreOnlyYieldsTwoThirdsOfPureOre", false).getBoolean(false); + GT_Mod.gregtechproxy.enableBlackGraniteOres = GregTech_API.sWorldgenFile.get("general", "enableBlackGraniteOres", GT_Mod.gregtechproxy.enableBlackGraniteOres); + GT_Mod.gregtechproxy.enableRedGraniteOres = GregTech_API.sWorldgenFile.get("general", "enableRedGraniteOres", GT_Mod.gregtechproxy.enableRedGraniteOres); + GT_Mod.gregtechproxy.enableMarbleOres = GregTech_API.sWorldgenFile.get("general", "enableMarbleOres", GT_Mod.gregtechproxy.enableMarbleOres); + GT_Mod.gregtechproxy.enableBasaltOres = GregTech_API.sWorldgenFile.get("general", "enableBasaltOres", GT_Mod.gregtechproxy.enableBasaltOres); + GT_Mod.gregtechproxy.gt6Pipe = tMainConfig.get("general", "GT6StyledPipesConnection", true).getBoolean(true); + GT_Mod.gregtechproxy.gt6Cable = tMainConfig.get("general", "GT6StyledWiresConnection", true).getBoolean(true); + GT_Mod.gregtechproxy.ic2EnergySourceCompat = tMainConfig.get("general", "Ic2EnergySourceCompat", true).getBoolean(true); + GT_Mod.gregtechproxy.costlyCableConnection = tMainConfig.get("general", "CableConnectionRequiresSolderingMaterial", false).getBoolean(false); + GT_LanguageManager.i18nPlaceholder = tMainConfig.get("general", "EnablePlaceholderForMaterialNamesInLangFile", true).getBoolean(true); + GT_MetaTileEntity_LongDistancePipelineBase.minimalDistancePoints = tMainConfig.get("general", "LongDistancePipelineMinimalDistancePoints", 64).getInt(64); + + GregTech_API.mUseOnlyGoodSolderingMaterials = GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.harderrecipes, "useonlygoodsolderingmaterials", GregTech_API.mUseOnlyGoodSolderingMaterials); + GT_Mod.gregtechproxy.mChangeHarvestLevels = GregTech_API.sMaterialProperties.get("havestLevel", "activateHarvestLevelChange", false);//TODO CHECK + if (GT_Mod.gregtechproxy.mChangeHarvestLevels) { + GT_Mod.gregtechproxy.mGraniteHavestLevel = GregTech_API.sMaterialProperties.get("havestLevel", "graniteHarvestLevel", 3); + GT_Mod.gregtechproxy.mMaxHarvestLevel = Math.min(15, GregTech_API.sMaterialProperties.get("havestLevel", "maxLevel", 7)); + Materials.getMaterialsMap().values().parallelStream().filter(tMaterial -> tMaterial != null && tMaterial.mToolQuality > 0 && tMaterial.mMetaItemSubID < GT_Mod.gregtechproxy.mHarvestLevel.length && tMaterial.mMetaItemSubID >= 0).forEach( + tMaterial -> GT_Mod.gregtechproxy.mHarvestLevel[tMaterial.mMetaItemSubID] = GregTech_API.sMaterialProperties.get("materialHavestLevel", tMaterial.mDefaultLocalName, tMaterial.mToolQuality) + ); + } + + if (tMainConfig.get("general", "hardermobspawners", true).getBoolean(true)) { + Blocks.mob_spawner.setHardness(500.0F).setResistance(6000000.0F); + } + GT_Mod.gregtechproxy.mOnline = tMainConfig.get(GT_Mod.aTextGeneral, "online", true).getBoolean(false); + + GT_Mod.gregtechproxy.mUpgradeCount = Math.min(64, Math.max(1, tMainConfig.get("features", "UpgradeStacksize", 4).getInt())); + for (OrePrefixes tPrefix : OrePrefixes.values()) { + if (tPrefix.mIsUsedForOreProcessing) { + tPrefix.mDefaultStackSize = ((byte) Math.min(64, Math.max(1, tMainConfig.get("features", "MaxOreStackSize", 64).getInt()))); + } else if (tPrefix == OrePrefixes.plank) { + tPrefix.mDefaultStackSize = ((byte) Math.min(64, Math.max(16, tMainConfig.get("features", "MaxPlankStackSize", 64).getInt()))); + } else if ((tPrefix == OrePrefixes.wood) || (tPrefix == OrePrefixes.treeLeaves) || (tPrefix == OrePrefixes.treeSapling) || (tPrefix == OrePrefixes.log)) { + tPrefix.mDefaultStackSize = ((byte) Math.min(64, Math.max(16, tMainConfig.get("features", "MaxLogStackSize", 64).getInt()))); + } else if (tPrefix.mIsUsedForBlocks) { + tPrefix.mDefaultStackSize = ((byte) Math.min(64, Math.max(16, tMainConfig.get("features", "MaxOtherBlockStackSize", 64).getInt()))); + } + } + } +} |