aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/GT_Mod.java
diff options
context:
space:
mode:
authorJason Mitchell <mitchej@gmail.com>2021-01-02 20:50:56 -0800
committerJason Mitchell <mitchej@gmail.com>2021-01-02 20:50:56 -0800
commit3b6bc659ee5a38644ce0c3e55dbc3363e3a7100e (patch)
tree444eebce14c88ddad3792c25084ebd51a3591f9e /src/main/java/gregtech/GT_Mod.java
parent84c3236766ed6520cb54d9667308fe8f2be606de (diff)
downloadGT5-Unofficial-3b6bc659ee5a38644ce0c3e55dbc3363e3a7100e.tar.gz
GT5-Unofficial-3b6bc659ee5a38644ce0c3e55dbc3363e3a7100e.tar.bz2
GT5-Unofficial-3b6bc659ee5a38644ce0c3e55dbc3363e3a7100e.zip
1) Remove mAddGTRecipesToIC2Machines (stolen from @Glease)
2) Batch (most) recipe map removals and additions (significant speedup) 3) Modernize old java constructs --> java8 (in the files touched)
Diffstat (limited to 'src/main/java/gregtech/GT_Mod.java')
-rw-r--r--src/main/java/gregtech/GT_Mod.java106
1 files changed, 41 insertions, 65 deletions
diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java
index 1844fb77c5..62148430b5 100644
--- a/src/main/java/gregtech/GT_Mod.java
+++ b/src/main/java/gregtech/GT_Mod.java
@@ -1,5 +1,6 @@
package gregtech;
+import com.google.common.base.Stopwatch;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.LoadController;
import cpw.mods.fml.common.Loader;
@@ -424,7 +425,6 @@ public class GT_Mod implements IGT_Mod {
gregtechproxy.mPollutionVegetationLimit = tMainConfig.get("Pollution", "VegetationLimit", 1000000).getInt(1000000);
gregtechproxy.mPollutionSourRainLimit = tMainConfig.get("Pollution", "SourRainLimit", 2000000).getInt(2000000);
gregtechproxy.mExplosionItemDrop = tMainConfig.get("general", "ExplosionItemDrops", false).getBoolean(false);
- gregtechproxy.mAddGTRecipesToIC2Machines = tMainConfig.get("general", "AddGTRecipesToIC2Machines", true).getBoolean(true);
gregtechproxy.mUndergroundOil.getConfig(tMainConfig, "undergroundfluid");
gregtechproxy.mEnableCleanroom = tMainConfig.get("general", "EnableCleanroom", true).getBoolean(true);
gregtechproxy.mLowGravProcessing = Loader.isModLoaded(GT_Values.MOD_ID_GC_CORE) && tMainConfig.get("general", "LowGravProcessing", true).getBoolean(true);
@@ -815,10 +815,10 @@ public class GT_Mod implements IGT_Mod {
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.storageblockcrafting, "tile.glowstone", false)) {
GT_ModHandler.removeRecipe(new ItemStack(Items.glowstone_dust, 1), new ItemStack(Items.glowstone_dust, 1), null, new ItemStack(Items.glowstone_dust, 1), new ItemStack(Items.glowstone_dust, 1));
}
- GT_ModHandler.removeRecipe(new ItemStack(Blocks.wooden_slab, 1, 0), new ItemStack(Blocks.wooden_slab, 1, 1), new ItemStack(Blocks.wooden_slab, 1, 2));
- GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.wooden_slab, 6, 0), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"WWW", 'W', new ItemStack(Blocks.planks, 1, 0)});
+ GT_ModHandler.removeRecipeDelayed(new ItemStack(Blocks.wooden_slab, 1, 0), new ItemStack(Blocks.wooden_slab, 1, 1), new ItemStack(Blocks.wooden_slab, 1, 2));
+ GT_ModHandler.addCraftingRecipe(new ItemStack(Blocks.wooden_slab, 6, 0), GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"WWW", 'W', new ItemStack(Blocks.planks, 1, 0)});
- //Save a copy of these list before activateOreDictHandler(), then loop over them.
+ // Save a copy of these list before activateOreDictHandler(), then loop over them.
Map<IRecipeInput, RecipeOutput> aMaceratorRecipeList = GT_ModHandler.getMaceratorRecipeList();
Map<IRecipeInput, RecipeOutput> aCompressorRecipeList = GT_ModHandler.getCompressorRecipeList();
Map<IRecipeInput, RecipeOutput> aExtractorRecipeList = GT_ModHandler.getExtractorRecipeList();
@@ -827,14 +827,18 @@ public class GT_Mod implements IGT_Mod {
GT_Log.out.println("GT_Mod: Activating OreDictionary Handler, this can take some time, as it scans the whole OreDictionary");
GT_FML_LOGGER.info("If your Log stops here, you were too impatient. Wait a bit more next time, before killing Minecraft with the Task Manager.");
- long ms = System.currentTimeMillis();
+
+ Stopwatch stopwatch = Stopwatch.createStarted();
gregtechproxy.activateOreDictHandler();
- GT_FML_LOGGER.info("Congratulations, you have been waiting long enough (" + (System.currentTimeMillis() - ms) / 1000 + "s / " + (System.currentTimeMillis() - ms) + "ms). Have a Cake.");
+ 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());
- //GT_Log.out.println("GT_Mod: sRodMaterialList cycles: " + GT_RecipeRegistrator.sRodMaterialList_cycles);
+
Set<Materials> replaceVanillaItemsSet = gregtechproxy.mUseGreatlyShrukenReplacementList ? Arrays.stream(Materials.values()).filter(GT_RecipeRegistrator::hasVanillaRecipes).collect(Collectors.toSet()) : new HashSet<>(Arrays.asList(Materials.values()));
+
+ stopwatch.reset();
+ stopwatch.start();
GT_FML_LOGGER.info("Replacing Vanilla Materials in recipes, please wait.");
ProgressManager.ProgressBar progressBar = ProgressManager.push("Register materials", replaceVanillaItemsSet.size());
@@ -853,14 +857,20 @@ public class GT_Mod implements IGT_Mod {
});
}
ProgressManager.pop(progressBar);
- GT_FML_LOGGER.info("Congratulations, you have been waiting long enough (" + (System.currentTimeMillis() - ms) / 1000 + "s / " + (System.currentTimeMillis() - ms) + "ms). Have a Cake.");
+ GT_FML_LOGGER.info("Congratulations, you have been waiting long enough (" + stopwatch.stop() + "). Have a Cake.");
+
+
+ stopwatch.reset();
+ stopwatch.start();
//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_FML_LOGGER.info("IC2 Removal (" + stopwatch.stop() + "). Have a Cake.");
+
+
if (GT_Values.D1) {
GT_ModHandler.sSingleNonBlockDamagableRecipeList.forEach(iRecipe -> GT_Log.out.println("=> " + iRecipe.getRecipeOutput().getDisplayName()));
}
@@ -888,61 +898,16 @@ public class GT_Mod implements IGT_Mod {
}
if (Loader.isModLoaded(MOD_ID_AE))
GT_MetaTileEntity_DigitalChestBase.registerAEIntegration();
- String tName = "";
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "blastfurnace"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "blockcutter"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "inductionFurnace"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "generator"), false)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "windMill"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "waterMill"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "solarPanel"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "centrifuge"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "electrolyzer"), false)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "compressor"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "electroFurnace"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "extractor"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "macerator"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "recycler"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "metalformer"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "orewashingplant"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "massFabricator"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + (tName = "replicator"), true)) {
- GT_ModHandler.removeRecipeByOutput(GT_ModHandler.getIC2Item(tName, 1L));
- }
+
+
+ Arrays.stream(new String[]{
+ "blastfurnace", "blockcutter", "inductionFurnace", "generator", "windMill", "waterMill", "solarPanel", "centrifuge", "electrolyzer", "compressor",
+ "electroFurnace", "extractor", "macerator", "recycler", "metalformer", "orewashingplant", "massFabricator", "replicator",
+ })
+ .filter(tName -> GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, aTextIC2 + tName, true))
+ .map(tName -> GT_ModHandler.getIC2Item(tName, 1L)).forEach(GT_ModHandler::removeRecipeByOutputDelayed);
+
+
if (gregtechproxy.mNerfedVanillaTools) {
GT_Log.out.println("GT_Mod: Nerfing Vanilla Tool Durability");
Items.wooden_sword.setMaxDamage(12);
@@ -976,9 +941,20 @@ public class GT_Mod implements IGT_Mod {
Items.diamond_hoe.setMaxDamage(768);
}
new GT_ExtremeDieselFuelLoader().run();
+
+
+ /*
+ * Until this point most crafting recipe additions, and removals, have been buffered.
+ * Go through, execute the removals in bulk, and then any deferred additions. The bulk removals in particular significantly speed up the recipe list
+ * modifications.
+ */
+
+ stopwatch.reset();
+ stopwatch.start();
GT_Log.out.println("GT_Mod: Adding buffered Recipes.");
GT_ModHandler.stopBufferingCraftingRecipes();
-
+ GT_FML_LOGGER.info("Executed delayed Crafting Recipes (" + stopwatch.stop() + "). Have a Cake.");
+
GT_Log.out.println("GT_Mod: Saving Lang File.");
GT_LanguageManager.sEnglishFile.save();
GregTech_API.sPostloadFinished = true;