From 5670419525fde1c177e0898b7da52ae8e7ca4263 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Sun, 15 Mar 2020 18:02:16 +0100 Subject: Refactored GT_Mod.java Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> --- src/main/java/gregtech/GT_Mod.java | 695 ++++++++++++++++++------------------- 1 file changed, 340 insertions(+), 355 deletions(-) (limited to 'src/main') diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 967c2e897e..156825c11c 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -67,42 +67,43 @@ import java.util.stream.Collectors; import static gregtech.api.enums.GT_Values.MOD_ID_AE; import static gregtech.api.enums.GT_Values.MOD_ID_FR; +@SuppressWarnings("ALL") @Mod(modid = "gregtech", name = "GregTech", version = "MC1710", useMetadata = false, - dependencies = " required-after:IC2;" + - " after:dreamcraft;"+ - " after:Forestry;" + - " after:PFAAGeologica;" + - " after:Thaumcraft;" + - " after:Railcraft;" + - " after:appliedenergistics2;" + - " after:ThermalExpansion;" + - " after:TwilightForest;" + - " after:harvestcraft;" + - " after:magicalcrops;" + - " after:BuildCraft|Transport;" + - " after:BuildCraft|Silicon;" + - " after:BuildCraft|Factory;" + - " after:BuildCraft|Energy;" + - " after:BuildCraft|Core;" + - " after:BuildCraft|Builders;" + - " after:GalacticraftCore;" + - " after:GalacticraftMars;" + - " after:GalacticraftPlanets;" + - " after:ThermalExpansion|Transport;" + - " after:ThermalExpansion|Energy;" + - " after:ThermalExpansion|Factory;" + - " after:RedPowerCore;" + - " after:RedPowerBase;" + - " after:RedPowerMachine;" + - " after:RedPowerCompat;" + - " after:RedPowerWiring;" + - " after:RedPowerLogic;" + - " after:RedPowerLighting;" + - " after:RedPowerWorld;" + - " after:RedPowerControl;" + - " after:UndergroundBiomes;" + - " after:TConstruct;" + - " after:Translocator;") + dependencies = " required-after:IC2;" + + " after:dreamcraft;" + + " after:Forestry;" + + " after:PFAAGeologica;" + + " after:Thaumcraft;" + + " after:Railcraft;" + + " after:appliedenergistics2;" + + " after:ThermalExpansion;" + + " after:TwilightForest;" + + " after:harvestcraft;" + + " after:magicalcrops;" + + " after:BuildCraft|Transport;" + + " after:BuildCraft|Silicon;" + + " after:BuildCraft|Factory;" + + " after:BuildCraft|Energy;" + + " after:BuildCraft|Core;" + + " after:BuildCraft|Builders;" + + " after:GalacticraftCore;" + + " after:GalacticraftMars;" + + " after:GalacticraftPlanets;" + + " after:ThermalExpansion|Transport;" + + " after:ThermalExpansion|Energy;" + + " after:ThermalExpansion|Factory;" + + " after:RedPowerCore;" + + " after:RedPowerBase;" + + " after:RedPowerMachine;" + + " after:RedPowerCompat;" + + " after:RedPowerWiring;" + + " after:RedPowerLogic;" + + " after:RedPowerLighting;" + + " after:RedPowerWorld;" + + " after:RedPowerControl;" + + " after:UndergroundBiomes;" + + " after:TConstruct;" + + " after:Translocator;") public class GT_Mod implements IGT_Mod { public static final int VERSION = 509, SUBVERSION = 33; public static final int TOTAL_VERSION = calculateTotalGTVersion(VERSION, SUBVERSION); @@ -117,7 +118,7 @@ public class GT_Mod implements IGT_Mod { private final String aTextIC2 = "ic2_"; public static final Logger GT_FML_LOGGER = LogManager.getLogger("GregTech GTNH"); - + static { if ((509 != GregTech_API.VERSION) || (509 != GT_ModHandler.VERSION) || (509 != GT_OreDictUnificator.VERSION) || (509 != GT_Recipe.VERSION) || (509 != GT_Utility.VERSION) || (509 != GT_RecipeRegistrator.VERSION) || (509 != Element.VERSION) || (509 != Materials.VERSION) || (509 != OrePrefixes.VERSION)) { throw new GT_ItsNotMyFaultException("One of your Mods included GregTech-API Files inside it's download, mention this to the Mod Author, who does this bad thing, and tell him/her to use reflection. I have added a Version check, to prevent Authors from breaking my Mod that way."); @@ -127,15 +128,15 @@ public class GT_Mod implements IGT_Mod { public GT_Mod() { try { Class.forName("ic2.core.IC2").getField("enableOreDictCircuit").set(null, Boolean.FALSE); - } catch (Throwable e) { + } catch (Throwable ignored) { } try { Class.forName("ic2.core.IC2").getField("enableCraftingBucket").set(null, Boolean.FALSE); - } catch (Throwable e) { + } catch (Throwable ignored) { } try { Class.forName("ic2.core.IC2").getField("enableEnergyInStorageBlockItems").set(null, Boolean.FALSE); - } catch (Throwable e) { + } catch (Throwable ignored) { } GT_Values.GT = this; GT_Values.DW = new GT_DummyWorld(); @@ -146,19 +147,30 @@ public class GT_Mod implements IGT_Mod { Textures.ItemIcons.VOID.name(); } + public static int calculateTotalGTVersion(int minorVersion) { + return calculateTotalGTVersion(VERSION, minorVersion); + } + + public static int calculateTotalGTVersion(int majorVersion, int minorVersion) { + return majorVersion * 1000 + minorVersion; + + } + @Mod.EventHandler public void onPreLoad(FMLPreInitializationEvent aEvent) { Locale.setDefault(Locale.ENGLISH); if (GregTech_API.sPreloadStarted) { return; } - try { - for (Runnable tRunnable : GregTech_API.sBeforeGTPreload) { + + for (Runnable tRunnable : GregTech_API.sBeforeGTPreload) { + try { tRunnable.run(); + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); } - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); } + File tFile = new File(new File(aEvent.getModConfigurationDirectory(), "GregTech"), "GregTech.cfg"); Configuration tMainConfig = new Configuration(tFile); tMainConfig.load(); @@ -241,10 +253,7 @@ public class GT_Mod implements IGT_Mod { 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("******************************************************************************"); - String tString; - for (Iterator i$ = tList.iterator(); i$.hasNext(); GT_Log.ore.println(tString)) { - tString = (String) i$.next(); - } + tList.forEach(GT_Log.ore::println); } catch (Throwable ignored) { } gregtechproxy.onPreLoad(); @@ -253,7 +262,7 @@ public class GT_Mod implements IGT_Mod { GT_Values.D1 = tMainConfig.get(aTextGeneral, "Debug", false).getBoolean(false); GT_Values.D2 = tMainConfig.get(aTextGeneral, "Debug2", false).getBoolean(false); - GT_Values.allow_broken_recipemap = tMainConfig.get(aTextGeneral, "debug allow broken recipemap",false).getBoolean(false); + GT_Values.allow_broken_recipemap = tMainConfig.get(aTextGeneral, "debug allow broken recipemap", false).getBoolean(false); GT_Values.debugCleanroom = tMainConfig.get(aTextGeneral, "debugCleanroom", false).getBoolean(false); GT_Values.debugDriller = tMainConfig.get(aTextGeneral, "debugDriller", false).getBoolean(false); GT_Values.debugWorldGen = tMainConfig.get(aTextGeneral, "debugWorldGen", false).getBoolean(false); @@ -263,17 +272,17 @@ public class GT_Mod implements IGT_Mod { GT_Values.debugBlockMiner = tMainConfig.get(aTextGeneral, "debugBlockMiner", false).getBoolean(false); GT_Values.debugBlockPump = tMainConfig.get(aTextGeneral, "debugBlockPump", false).getBoolean(false); GT_Values.debugEntityCramming = tMainConfig.get(aTextGeneral, "debugEntityCramming", false).getBoolean(false); - GT_Values.oreveinPercentage = tMainConfig.get(aTextGeneral, "oreveinPercentage_100",100).getInt(100); - GT_Values.oreveinAttempts = tMainConfig.get(aTextGeneral, "oreveinAttempts_64",64).getInt(64); - GT_Values.oreveinMaxPlacementAttempts = tMainConfig.get(aTextGeneral, "oreveinMaxPlacementAttempts_8",8).getInt(8); + GT_Values.oreveinPercentage = tMainConfig.get(aTextGeneral, "oreveinPercentage_100", 100).getInt(100); + GT_Values.oreveinAttempts = tMainConfig.get(aTextGeneral, "oreveinAttempts_64", 64).getInt(64); + GT_Values.oreveinMaxPlacementAttempts = tMainConfig.get(aTextGeneral, "oreveinMaxPlacementAttempts_8", 8).getInt(8); GT_Values.oreveinPlacerOres = tMainConfig.get(aTextGeneral, "oreveinPlacerOres", true).getBoolean(true); - GT_Values.oreveinPlacerOresMultiplier = tMainConfig.get(aTextGeneral, "oreveinPlacerOresMultiplier",2).getInt(2); + GT_Values.oreveinPlacerOresMultiplier = tMainConfig.get(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.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); GregTech_API.TICKS_FOR_LAG_AVERAGING = tMainConfig.get(aTextGeneral, "TicksForLagAveragingWithScanner", 25).getInt(25); GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING = tMainConfig.get(aTextGeneral, "MillisecondsPassedInGTTileEntityUntilLagWarning", 100).getInt(100); @@ -304,20 +313,19 @@ public class GT_Mod implements IGT_Mod { GregTech_API.sDoShowAllItemsInCreative = tMainConfig.get(aTextGeneral, "show_all_metaitems_in_creative_and_NEI", false).getBoolean(false); GregTech_API.sMultiThreadedSounds = tMainConfig.get(aTextGeneral, "sound_multi_threading", false).getBoolean(false); String SBdye0 = "ColorModulation."; - for (Dyes tDye : Dyes.values()) { - if ((tDye != Dyes._NULL) && (tDye.mIndex < 0)) { - String SBdye1 = new StringBuilder(18).append(SBdye0).append(tDye).toString(); - 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])))); - } - } + 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])))); + } + ); gregtechproxy.mMaxEqualEntitiesAtOneSpot = tMainConfig.get(aTextGeneral, "MaxEqualEntitiesAtOneSpot", 3).getInt(3); gregtechproxy.mSkeletonsShootGTArrows = tMainConfig.get(aTextGeneral, "SkeletonsShootGTArrows", 16).getInt(16); gregtechproxy.mFlintChance = tMainConfig.get(aTextGeneral, "FlintAndSteelChance", 30).getInt(30); gregtechproxy.mItemDespawnTime = tMainConfig.get(aTextGeneral, "ItemDespawnTime", 6000).getInt(6000); - gregtechproxy.mAllowSmallBoilerAutomation = tMainConfig.get(aTextGeneral,"AllowSmallBoilerAutomation",false).getBoolean(false); - gregtechproxy.mHardMachineCasings= tMainConfig.get(aTextGeneral,"HardMachineCasings",true).getBoolean(true); + gregtechproxy.mAllowSmallBoilerAutomation = tMainConfig.get(aTextGeneral, "AllowSmallBoilerAutomation", false).getBoolean(false); + gregtechproxy.mHardMachineCasings = tMainConfig.get(aTextGeneral, "HardMachineCasings", true).getBoolean(true); gregtechproxy.mDisableVanillaOres = tMainConfig.get(aTextGeneral, "DisableVanillaOres", true).getBoolean(true); gregtechproxy.mNerfDustCrafting = tMainConfig.get(aTextGeneral, "NerfDustCrafting", true).getBoolean(true); gregtechproxy.mIncreaseDungeonLoot = tMainConfig.get(aTextGeneral, "IncreaseDungeonLoot", true).getBoolean(true); @@ -368,7 +376,7 @@ public class GT_Mod implements IGT_Mod { 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"); - gregtechproxy.mForceFreeFace = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "forceFreeFace",true); + gregtechproxy.mForceFreeFace = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "forceFreeFace", true); gregtechproxy.mBrickedBlastFurnace = tMainConfig.get("general", "BrickedBlastFurnace", true).getBoolean(true); gregtechproxy.mEasierIVPlusCables = tMainConfig.get("general", "EasierEVPlusCables", false).getBoolean(false); gregtechproxy.mMixedOreOnlyYieldsTwoThirdsOfPureOre = tMainConfig.get("general", "MixedOreOnlyYieldsTwoThirdsOfPureOre", false).getBoolean(false); @@ -384,14 +392,12 @@ public class GT_Mod implements IGT_Mod { GregTech_API.mUseOnlyGoodSolderingMaterials = GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.harderrecipes, "useonlygoodsolderingmaterials", GregTech_API.mUseOnlyGoodSolderingMaterials); gregtechproxy.mChangeHarvestLevels = GregTech_API.sMaterialProperties.get("havestLevel", "activateHarvestLevelChange", false);//TODO CHECK - if(gregtechproxy.mChangeHarvestLevels) { + if (gregtechproxy.mChangeHarvestLevels) { gregtechproxy.mGraniteHavestLevel = GregTech_API.sMaterialProperties.get("havestLevel", "graniteHarvestLevel", 3); gregtechproxy.mMaxHarvestLevel = Math.min(15, GregTech_API.sMaterialProperties.get("havestLevel", "maxLevel", 7)); - for (Materials tMaterial : Materials.values()) { - if (tMaterial != null && tMaterial.mToolQuality > 0 && tMaterial.mMetaItemSubID < gregtechproxy.mHarvestLevel.length && tMaterial.mMetaItemSubID >= 0) { - gregtechproxy.mHarvestLevel[tMaterial.mMetaItemSubID] = GregTech_API.sMaterialProperties.get("materialHavestLevel", tMaterial.mDefaultLocalName, tMaterial.mToolQuality); - } - } + Materials.getMaterialsMap().values().parallelStream().filter(tMaterial -> tMaterial != null && tMaterial.mToolQuality > 0 && tMaterial.mMetaItemSubID < gregtechproxy.mHarvestLevel.length && tMaterial.mMetaItemSubID >= 0).forEach( + tMaterial -> gregtechproxy.mHarvestLevel[tMaterial.mMetaItemSubID] = GregTech_API.sMaterialProperties.get("materialHavestLevel", tMaterial.mDefaultLocalName, tMaterial.mToolQuality) + ); } if (tMainConfig.get("general", "hardermobspawners", true).getBoolean(true)) { @@ -424,11 +430,8 @@ public class GT_Mod implements IGT_Mod { GT_Log.out.println("GT_Mod: Generating Lang-File"); GT_LanguageManager.sEnglishFile = new Configuration(new File(aEvent.getModConfigurationDirectory().getParentFile(), "GregTech.lang")); GT_LanguageManager.sEnglishFile.load(); - - for (Materials aMaterial : Materials.values()) { - if (aMaterial != null) - aMaterial.mLocalizedName = GT_LanguageManager.addStringLocalization("Material." + aMaterial.mName.toLowerCase(), aMaterial.mDefaultLocalName); - } + + Materials.getMaterialsMap().values().parallelStream().filter(Objects::nonNull).forEach(aMaterial -> aMaterial.mLocalizedName = GT_LanguageManager.addStringLocalization("Material." + aMaterial.mName.toLowerCase(), aMaterial.mDefaultLocalName)); GT_Log.out.println("GT_Mod: Removing all original Scrapbox Drops."); try { @@ -446,72 +449,83 @@ public class GT_Mod implements IGT_Mod { EntityRegistry.registerModEntity(GT_Entity_Arrow_Potion.class, "GT_Entity_Arrow_Potion", 2, GT_Values.GT, 160, 1, true); GT_FML_LOGGER.info("preReader"); - List oreTags = new ArrayList(); - if(Loader.isModLoaded("MineTweaker3")){ - File globalDir = new File("scripts"); - if (globalDir.exists()){ - List 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));} - } - } - } - } - } - } - } - 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 mMTTags = new ArrayList(); - for(String test : oreTags){ - if(StringUtils.startsWithAny(test, preS)){ - mMTTags.add(test); - if(GT_Values.D1) - GT_FML_LOGGER.info("oretag: "+test); - }} - + List oreTags = new ArrayList<>(); + if (Loader.isModLoaded("MineTweaker3")) { + File globalDir = new File("scripts"); + if (globalDir.exists()) { + List 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)); + } + } + } + } + } + } + } + } + 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 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) { @@ -554,7 +568,7 @@ public class GT_Mod implements IGT_Mod { GT_FML_LOGGER.info("noPrefix " + reEnable); } } - + new GT_Loader_OreProcessing().run(); new GT_Loader_OreDictionary().run(); new GT_Loader_ItemData().run(); @@ -610,16 +624,16 @@ public class GT_Mod implements IGT_Mod { */ double outputMultiplier = Math.min(GregTech_API.sOPStuff.get(ConfigCategories.Recipes.gregtechrecipes, "StoneDustOutputMultiplier", 0.6), 1.0); if (GregTech_API.sOPStuff.get(ConfigCategories.Recipes.gregtechrecipes, "StoneDustCentrifugation", false)) { - int fullChance = (int)(10000 * outputMultiplier); - int[] chances = new int[]{fullChance, fullChance, fullChance, fullChance, fullChance, (int)(5500 * outputMultiplier)}; - GT_Values.RA.addCentrifugeRecipe(Materials.Stone.getDust(1), GT_Values.NI, GT_Values.NF, GT_Values.NF, - Materials.Quartzite.getDustSmall(1),Materials.PotassiumFeldspar.getDustSmall(1),Materials.Marble.getDustTiny(2), - Materials.Biotite.getDustTiny(1), Materials.MetalMixture.getDustTiny(1), Materials.Sodalite.getDustTiny(1), - chances, 600, 120); - GT_Values.RA.addCentrifugeRecipe(Materials.MetalMixture.getDust(1), GT_Values.NI, GT_Values.NF, GT_Values.NF, - Materials.BandedIron.getDustSmall(1), Materials.Bauxite.getDustSmall(1), Materials.Pyrolusite.getDustTiny(2), - Materials.Barite.getDustTiny(1), Materials.Chromite.getDustTiny(1), Materials.Ilmenite.getDustTiny(1), - new int[]{10000, 10000, 10000, 10000, 10000, 6000}, 600, 1920); + int fullChance = (int) (10000 * outputMultiplier); + int[] chances = new int[]{fullChance, fullChance, fullChance, fullChance, fullChance, (int) (5500 * outputMultiplier)}; + GT_Values.RA.addCentrifugeRecipe(Materials.Stone.getDust(1), GT_Values.NI, GT_Values.NF, GT_Values.NF, + Materials.Quartzite.getDustSmall(1), Materials.PotassiumFeldspar.getDustSmall(1), Materials.Marble.getDustTiny(2), + Materials.Biotite.getDustTiny(1), Materials.MetalMixture.getDustTiny(1), Materials.Sodalite.getDustTiny(1), + chances, 600, 120); + GT_Values.RA.addCentrifugeRecipe(Materials.MetalMixture.getDust(1), GT_Values.NI, GT_Values.NF, GT_Values.NF, + Materials.BandedIron.getDustSmall(1), Materials.Bauxite.getDustSmall(1), Materials.Pyrolusite.getDustTiny(2), + Materials.Barite.getDustTiny(1), Materials.Chromite.getDustTiny(1), Materials.Ilmenite.getDustTiny(1), + new int[]{10000, 10000, 10000, 10000, 10000, 6000}, 600, 1920); } double ashOutputMultiplier = Math.min(GregTech_API.sOPStuff.get(ConfigCategories.Recipes.gregtechrecipes, "AshOutputMultiplier", 1.0), 1.0); if (GregTech_API.sOPStuff.get(ConfigCategories.Recipes.gregtechrecipes, "AshYieldsAlkaliMetalOxides", true)) { @@ -627,14 +641,14 @@ public class GT_Mod implements IGT_Mod { (int) (6000 * ashOutputMultiplier), (int) (500 * ashOutputMultiplier), (int) (5000 * ashOutputMultiplier), (int) (2500 * ashOutputMultiplier)}; GT_Values.RA.addCentrifugeRecipe(Materials.Ash.getDust(1), GT_Values.NI, GT_Values.NF, GT_Values.NF, - Materials.Quicklime.getDustSmall(2), Materials.Potash.getDustSmall(1), Materials.Magnesia.getDustSmall(1), + Materials.Quicklime.getDustSmall(2), Materials.Potash.getDustSmall(1), Materials.Magnesia.getDustSmall(1), Materials.PhosphorousPentoxide.getDustTiny(1), Materials.SodaAsh.getDustTiny(1), Materials.BandedIron.getDustTiny(1), outputChances, 240, 30); } else { GT_Values.RA.addCentrifugeRecipe(Materials.Ash.getDust(1), GT_Values.NI, GT_Values.NF, GT_Values.NF, Materials.Carbon.getDust(1), GT_Values.NI, GT_Values.NI, GT_Values.NI, GT_Values.NI, GT_Values.NI, new int[]{(int) (10000 * ashOutputMultiplier), 0, 0, 0, 0, 0}, 40, 16); - } + } if (gregtechproxy.mSortToTheEnd) { try { GT_Log.out.println("GT_Mod: Sorting GregTech to the end of the Mod List for further processing."); @@ -642,7 +656,7 @@ public class GT_Mod implements IGT_Mod { List tModList = tLoadController.getActiveModList(); List tNewModsList = new ArrayList<>(); ModContainer tGregTech = null; - short tModList_sS= (short) tModList.size(); + 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")) { @@ -664,15 +678,17 @@ public class GT_Mod implements IGT_Mod { GregTech_API.sPreloadFinished = true; GT_Log.out.println("GT_Mod: Preload-Phase finished!"); GT_Log.ore.println("GT_Mod: Preload-Phase finished!"); - try { - for (Runnable tRunnable : GregTech_API.sAfterGTPreload) { + + for (Runnable tRunnable : GregTech_API.sAfterGTPreload) { + try { tRunnable.run(); + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); } - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); } + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) - GT_Assemblyline_Server.fillMap(aEvent); + GT_Assemblyline_Server.fillMap(aEvent); } @Mod.EventHandler @@ -680,19 +696,22 @@ public class GT_Mod implements IGT_Mod { if (GregTech_API.sLoadStarted) { return; } - try { - for (Runnable tRunnable : GregTech_API.sBeforeGTLoad) { + + for (Runnable tRunnable : GregTech_API.sBeforeGTLoad) { + try { tRunnable.run(); + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); } - } catch (Throwable e) {e.printStackTrace(GT_Log.err);} + } if (Loader.isModLoaded(MOD_ID_FR)) new GT_Bees(); - - //Disable Low Grav regardless of config if Cleanroom is disabled. - if (!gregtechproxy.mEnableCleanroom){ - gregtechproxy.mLowGravProcessing = false; - } + + //Disable Low Grav regardless of config if Cleanroom is disabled. + if (!gregtechproxy.mEnableCleanroom) { + gregtechproxy.mLowGravProcessing = false; + } gregtechproxy.onLoad(); if (gregtechproxy.mSortToTheEnd) { @@ -703,11 +722,15 @@ public class GT_Mod implements IGT_Mod { GregTech_API.sLoadFinished = true; GT_Log.out.println("GT_Mod: Load-Phase finished!"); GT_Log.ore.println("GT_Mod: Load-Phase finished!"); - try { - for (Runnable tRunnable : GregTech_API.sAfterGTLoad) { + + for (Runnable tRunnable : GregTech_API.sAfterGTLoad) { + try { tRunnable.run(); + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); } - } catch (Throwable e) {e.printStackTrace(GT_Log.err);} + } + } @Mod.EventHandler @@ -715,11 +738,15 @@ public class GT_Mod implements IGT_Mod { if (GregTech_API.sPostloadStarted) { return; } - try { - for (Runnable tRunnable : GregTech_API.sBeforeGTPostload) { + + for (Runnable tRunnable : GregTech_API.sBeforeGTPostload) { + try { tRunnable.run(); + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); } - } catch (Throwable e) {e.printStackTrace(GT_Log.err);} + } + gregtechproxy.onPostLoad(); if (gregtechproxy.mSortToTheEnd) { gregtechproxy.registerUnificationEntries(); @@ -762,7 +789,7 @@ public class GT_Mod implements IGT_Mod { long ms = System.currentTimeMillis(); 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_Log.out.println("GT_Mod: List of Lists of Tool Recipes: "+GT_ModHandler.sSingleNonBlockDamagableRecipeList_list.toString()); + 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); @@ -792,10 +819,7 @@ public class GT_Mod implements IGT_Mod { GT_ModHandler.addIC2RecipesToGT(aThermalCentrifugeRecipeList, GT_Recipe.GT_Recipe_Map.sThermalCentrifugeRecipes, true, true, true); if (GT_Values.D1) { - IRecipe tRecipe; - for (Iterator i$ = GT_ModHandler.sSingleNonBlockDamagableRecipeList.iterator(); i$.hasNext(); GT_Log.out.println("=> " + tRecipe.getRecipeOutput().getDisplayName())) { - tRecipe = (IRecipe) i$.next(); - } + GT_ModHandler.sSingleNonBlockDamagableRecipeList.forEach(iRecipe -> GT_Log.out.println("=> " + iRecipe.getRecipeOutput().getDisplayName())); } new GT_CraftingRecipeLoader().run(); if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.disabledrecipes, "ic2forgehammer", true)) { @@ -814,7 +838,7 @@ public class GT_Mod implements IGT_Mod { 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); } } - + if (Loader.isModLoaded(MOD_ID_FR)) { GT_Forestry_Compat.transferCentrifugeRecipes(); GT_Forestry_Compat.transferSqueezerRecipes(); @@ -916,16 +940,18 @@ public class GT_Mod implements IGT_Mod { GregTech_API.sPostloadFinished = true; GT_Log.out.println("GT_Mod: PostLoad-Phase finished!"); GT_Log.ore.println("GT_Mod: PostLoad-Phase finished!"); - try { - for (Runnable tRunnable : GregTech_API.sAfterGTPostload) { + for (Runnable tRunnable : GregTech_API.sAfterGTPostload) { + try { tRunnable.run(); + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); } - } catch (Throwable e) {e.printStackTrace(GT_Log.err);} + } 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); } @@ -935,16 +961,16 @@ public class GT_Mod implements IGT_Mod { 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); + 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")){ + 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); + 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); } } } - for (Materials tMaterial : Materials.values()) { + Materials.getMaterialsMap().values().parallelStream().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"); @@ -964,26 +990,28 @@ public class GT_Mod implements IGT_Mod { 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); + }); + + 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); - if(GregTech_API.mOutputRF||GregTech_API.mInputRF){ + if (GregTech_API.mOutputRF || GregTech_API.mInputRF) { GT_Utility.checkAvailabilities(); - if(!GT_Utility.RF_CHECK){ + if (!GT_Utility.RF_CHECK) { GregTech_API.mOutputRF = false; GregTech_API.mInputRF = false; } } - + addSolidFakeLargeBoilerFuels(); - + achievements = new GT_Achievements(); - GT_Recipe.GTppRecipeHelper=true; + GT_Recipe.GTppRecipeHelper = true; GT_Log.out.println("GT_Mod: Loading finished, deallocating temporary Init Variables."); GregTech_API.sBeforeGTPreload = null; GregTech_API.sAfterGTPreload = null; @@ -993,7 +1021,6 @@ public class GT_Mod implements IGT_Mod { GregTech_API.sAfterGTPostload = null; - CreativeTabs mainTab = new CreativeTabs("GTtools") { @SideOnly(Side.CLIENT) @Override @@ -1013,12 +1040,12 @@ public class GT_Mod implements IGT_Mod { 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)); + 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); @@ -1027,17 +1054,35 @@ public class GT_Mod implements IGT_Mod { } @Mod.EventHandler - public void onServerAboutToStart(FMLServerAboutToStartEvent aEvent){ + public void onServerStarted(FMLServerStartedEvent aEvent) { + gregtechproxy.onServerStarted(); + } + + @Mod.EventHandler + public void onServerAboutToStart(FMLServerAboutToStartEvent aEvent) { gregtechproxy.onServerAboutToStart(); } +// public void onIDChangingEvent(FMLModIdMappingEvent aEvent) +// { +// GT_Utility.reInit(); +// GT_Recipe.reInit(); +// Map tMap; +// for (Iterator i$ = GregTech_API.sItemStackMappings.iterator(); i$.hasNext(); ) { +// tMap = (Map)i$.next(); +// } +// } @Mod.EventHandler public void onServerStarting(FMLServerStartingEvent aEvent) { - try { - for (Runnable tRunnable : GregTech_API.sBeforeGTServerstart) { + + for (Runnable tRunnable : GregTech_API.sBeforeGTServerstart) { + try { tRunnable.run(); + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); } - } catch (Throwable e) {e.printStackTrace(GT_Log.err);} + } + gregtechproxy.onServerStarting(); //Check for more IC2 recipes on ServerStart to also catch MineTweaker additions GT_ModHandler.addIC2RecipesToGT(GT_ModHandler.getMaceratorRecipeList(), GT_Recipe.GT_Recipe_Map.sMaceratorRecipes, true, true, true); @@ -1048,66 +1093,18 @@ public class GT_Mod implements IGT_Mod { GT_Log.out.println("GT_Mod: Unificating outputs of all known Recipe Types."); ArrayList tStacks = new ArrayList<>(10000); GT_Log.out.println("GT_Mod: IC2 Machines"); - for (RecipeOutput tRecipe : ic2.api.recipe.Recipes.cannerBottle.getRecipes().values()) { - ItemStack tStack; - for (Iterator i$ = tRecipe.items.iterator(); i$.hasNext(); tStacks.add(tStack)) { - tStack = (ItemStack) i$.next(); - } - } - for (RecipeOutput tRecipe : ic2.api.recipe.Recipes.centrifuge.getRecipes().values()) { - ItemStack tStack; - for (Iterator i$ = tRecipe.items.iterator(); i$.hasNext(); tStacks.add(tStack)) { - tStack = (ItemStack) i$.next(); - } - } - for (RecipeOutput tRecipe : ic2.api.recipe.Recipes.compressor.getRecipes().values()) { - ItemStack tStack; - for (Iterator i$ = tRecipe.items.iterator(); i$.hasNext(); tStacks.add(tStack)) { - tStack = (ItemStack) i$.next(); - } - } - for (RecipeOutput tRecipe : ic2.api.recipe.Recipes.extractor.getRecipes().values()) { - ItemStack tStack; - for (Iterator i$ = tRecipe.items.iterator(); i$.hasNext(); tStacks.add(tStack)) { - tStack = (ItemStack) i$.next(); - } - } - for (RecipeOutput tRecipe : ic2.api.recipe.Recipes.macerator.getRecipes().values()) { - ItemStack tStack; - for (Iterator i$ = tRecipe.items.iterator(); i$.hasNext(); tStacks.add(tStack)) { - tStack = (ItemStack) i$.next(); - } - } - for (RecipeOutput tRecipe : ic2.api.recipe.Recipes.metalformerCutting.getRecipes().values()) { - ItemStack tStack; - for (Iterator i$ = tRecipe.items.iterator(); i$.hasNext(); tStacks.add(tStack)) { - tStack = (ItemStack) i$.next(); - } - } - for (RecipeOutput tRecipe : ic2.api.recipe.Recipes.metalformerExtruding.getRecipes().values()) { - ItemStack tStack; - for (Iterator i$ = tRecipe.items.iterator(); i$.hasNext(); tStacks.add(tStack)) { - tStack = (ItemStack) i$.next(); - } - } - for (RecipeOutput tRecipe : ic2.api.recipe.Recipes.metalformerRolling.getRecipes().values()) { - ItemStack tStack; - for (Iterator i$ = tRecipe.items.iterator(); i$.hasNext(); tStacks.add(tStack)) { - tStack = (ItemStack) i$.next(); - } - } - for (RecipeOutput tRecipe : ic2.api.recipe.Recipes.matterAmplifier.getRecipes().values()) { - ItemStack tStack; - for (Iterator i$ = tRecipe.items.iterator(); i$.hasNext(); tStacks.add(tStack)) { - tStack = (ItemStack) i$.next(); - } - } - for (RecipeOutput tRecipe : ic2.api.recipe.Recipes.oreWashing.getRecipes().values()) { - ItemStack tStack; - for (Iterator i$ = tRecipe.items.iterator(); i$.hasNext(); tStacks.add(tStack)) { - tStack = (ItemStack) i$.next(); - } - } + + ic2.api.recipe.Recipes.cannerBottle.getRecipes().values().stream().map(t -> t.items).forEach(tStacks::addAll); + ic2.api.recipe.Recipes.centrifuge.getRecipes().values().stream().map(t -> t.items).forEach(tStacks::addAll); + ic2.api.recipe.Recipes.compressor.getRecipes().values().stream().map(t -> t.items).forEach(tStacks::addAll); + ic2.api.recipe.Recipes.extractor.getRecipes().values().stream().map(t -> t.items).forEach(tStacks::addAll); + ic2.api.recipe.Recipes.macerator.getRecipes().values().stream().map(t -> t.items).forEach(tStacks::addAll); + ic2.api.recipe.Recipes.metalformerCutting.getRecipes().values().stream().map(t -> t.items).forEach(tStacks::addAll); + ic2.api.recipe.Recipes.metalformerExtruding.getRecipes().values().stream().map(t -> t.items).forEach(tStacks::addAll); + ic2.api.recipe.Recipes.metalformerRolling.getRecipes().values().stream().map(t -> t.items).forEach(tStacks::addAll); + ic2.api.recipe.Recipes.matterAmplifier.getRecipes().values().stream().map(t -> t.items).forEach(tStacks::addAll); + ic2.api.recipe.Recipes.oreWashing.getRecipes().values().stream().map(t -> t.items).forEach(tStacks::addAll); + GT_Log.out.println("GT_Mod: Dungeon Loot"); for (WeightedRandomChestContent tContent : ChestGenHooks.getInfo("dungeonChest").getItems(new XSTR())) { tStacks.add(tContent.theItemId); @@ -1140,10 +1137,9 @@ public class GT_Mod implements IGT_Mod { tStacks.add(tContent.theItemId); } GT_Log.out.println("GT_Mod: Smelting"); - Object tStack; - for (Iterator i$ = FurnaceRecipes.smelting().getSmeltingList().values().iterator(); i$.hasNext(); tStacks.add((ItemStack) tStack)) { - tStack = i$.next(); - } + + FurnaceRecipes.smelting().getSmeltingList().values().forEach(k -> tStacks.add((ItemStack) k)); + if (gregtechproxy.mCraftingUnification) { GT_Log.out.println("GT_Mod: Crafting Recipes"); for (Object tRecipe : CraftingManager.getInstance().getRecipeList()) { @@ -1177,17 +1173,40 @@ public class GT_Mod implements IGT_Mod { GregTech_API.mServerStarted = true; GT_Log.out.println("GT_Mod: ServerStarting-Phase finished!"); GT_Log.ore.println("GT_Mod: ServerStarting-Phase finished!"); - try { - for (Runnable tRunnable : GregTech_API.sAfterGTServerstart) { + + for (Runnable tRunnable : GregTech_API.sAfterGTServerstart) { + try { tRunnable.run(); + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); } - } catch (Throwable e) {e.printStackTrace(GT_Log.err);} + } + aEvent.registerServerCommand(new GT_Command()); } - @Mod.EventHandler - public void onServerStarted(FMLServerStartedEvent aEvent) { - gregtechproxy.onServerStarted(); + public boolean isServerSide() { + return gregtechproxy.isServerSide(); + } + + public boolean isClientSide() { + return gregtechproxy.isClientSide(); + } + + public boolean isBukkitSide() { + return gregtechproxy.isBukkitSide(); + } + + public EntityPlayer getThePlayer() { + return gregtechproxy.getThePlayer(); + } + + public int addArmor(String aArmorPrefix) { + return gregtechproxy.addArmor(aArmorPrefix); + } + + public void doSonictronSound(ItemStack aStack, World aWorld, double aX, double aY, double aZ) { + gregtechproxy.doSonictronSound(aStack, aWorld, aX, aY, aZ); } @Mod.EventHandler @@ -1198,26 +1217,23 @@ public class GT_Mod implements IGT_Mod { for (Map gt_itemStackMap : GregTech_API.sItemStackMappings) { GT_Utility.reMap((Map) gt_itemStackMap); } - } catch (Throwable e) {e.printStackTrace(GT_Log.err);} + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } } -// public void onIDChangingEvent(FMLModIdMappingEvent aEvent) -// { -// GT_Utility.reInit(); -// GT_Recipe.reInit(); -// Map tMap; -// for (Iterator i$ = GregTech_API.sItemStackMappings.iterator(); i$.hasNext(); ) { -// tMap = (Map)i$.next(); -// } -// } @Mod.EventHandler public void onServerStopping(FMLServerStoppingEvent aEvent) { - try { - for (Runnable tRunnable : GregTech_API.sBeforeGTServerstop) { + + for (Runnable tRunnable : GregTech_API.sBeforeGTServerstop) { + try { tRunnable.run(); + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); } - } catch (Throwable e) {e.printStackTrace(GT_Log.err);} + } + gregtechproxy.onServerStopping(); try { if ((GT_Values.D1) || (GT_Log.out != System.out)) { @@ -1285,73 +1301,42 @@ public class GT_Mod implements IGT_Mod { e.printStackTrace(GT_Log.err); } } - try { - for (Runnable tRunnable : GregTech_API.sAfterGTServerstop) { + for (Runnable tRunnable : GregTech_API.sAfterGTServerstop) { + try { tRunnable.run(); + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); } - } catch (Throwable e) {e.printStackTrace(GT_Log.err);} - } - - public boolean isServerSide() { - return gregtechproxy.isServerSide(); - } - - public boolean isClientSide() { - return gregtechproxy.isClientSide(); - } - - public boolean isBukkitSide() { - return gregtechproxy.isBukkitSide(); - } - - public EntityPlayer getThePlayer() { - return gregtechproxy.getThePlayer(); - } - - public int addArmor(String aArmorPrefix) { - return gregtechproxy.addArmor(aArmorPrefix); + } } - public void doSonictronSound(ItemStack aStack, World aWorld, double aX, double aY, double aZ) { - gregtechproxy.doSonictronSound(aStack, aWorld, aX, aY, aZ); - } - - private void addSolidFakeLargeBoilerFuels(){ + private 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)); + 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)); + GT_Recipe.GT_Recipe_Map.sLargeBoilerFakeFuels.addSolidRecipe(GT_ModHandler.getModItem("Thaumcraft", "ItemResource", 1)); } } - - public static int calculateTotalGTVersion(int minorVersion){ - return calculateTotalGTVersion(VERSION, minorVersion); - } - - public static int calculateTotalGTVersion(int majorVersion, int minorVersion){ - return majorVersion * 1000 + minorVersion; - - } -} +} \ No newline at end of file -- cgit From 509d05f5d8447a9852e375ad25df9f943e1fca2e Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Sun, 15 Mar 2020 18:02:35 +0100 Subject: Refactored GT_Recipe.java Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> --- src/main/java/gregtech/api/util/GT_Recipe.java | 411 +++++++++++++------------ 1 file changed, 213 insertions(+), 198 deletions(-) (limited to 'src/main') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 21bac2b246..c67b398cea 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -79,8 +79,8 @@ public class GT_Recipe implements Comparable { private String[] neiDesc = null; private GT_Recipe(GT_Recipe aRecipe) { - mInputs = GT_Utility.copyStackArray((Object[]) aRecipe.mInputs); - mOutputs = GT_Utility.copyStackArray((Object[]) aRecipe.mOutputs); + mInputs = GT_Utility.copyStackArray(aRecipe.mInputs); + mOutputs = GT_Utility.copyStackArray(aRecipe.mOutputs); mSpecialItems = aRecipe.mSpecialItems; mChances = aRecipe.mChances; mFluidInputs = GT_Utility.copyFluidArray(aRecipe.mFluidInputs); @@ -95,12 +95,18 @@ public class GT_Recipe implements Comparable { mHidden = aRecipe.mHidden; } protected GT_Recipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - if (aInputs == null) aInputs = new ItemStack[0]; - if (aOutputs == null) aOutputs = new ItemStack[0]; - if (aFluidInputs == null) aFluidInputs = new FluidStack[0]; - if (aFluidOutputs == null) aFluidOutputs = new FluidStack[0]; - if (aChances == null) aChances = new int[aOutputs.length]; - if (aChances.length < aOutputs.length) aChances = Arrays.copyOf(aChances, aOutputs.length); + if (aInputs == null) + aInputs = new ItemStack[0]; + if (aOutputs == null) + aOutputs = new ItemStack[0]; + if (aFluidInputs == null) + aFluidInputs = new FluidStack[0]; + if (aFluidOutputs == null) + aFluidOutputs = new FluidStack[0]; + if (aChances == null) + aChances = new int[aOutputs.length]; + if (aChances.length < aOutputs.length) + aChances = Arrays.copyOf(aChances, aOutputs.length); aInputs = GT_Utility.getArrayListWithoutTrailingNulls(aInputs).toArray(new ItemStack[0]); aOutputs = GT_Utility.getArrayListWithoutTrailingNulls(aOutputs).toArray(new ItemStack[0]); @@ -110,27 +116,32 @@ public class GT_Recipe implements Comparable { GT_OreDictUnificator.setStackArray(true, aInputs); GT_OreDictUnificator.setStackArray(true, aOutputs); - for (ItemStack tStack : aOutputs) GT_Utility.updateItemStack(tStack); + for (ItemStack tStack : aOutputs) + GT_Utility.updateItemStack(tStack); - for (int i = 0; i < aChances.length; i++) if (aChances[i] <= 0) aChances[i] = 10000; - for (int i = 0; i < aFluidInputs.length; i++) aFluidInputs[i] = new GT_FluidStack(aFluidInputs[i]); - for (int i = 0; i < aFluidOutputs.length; i++) aFluidOutputs[i] = new GT_FluidStack(aFluidOutputs[i]); + for (int i = 0; i < aChances.length; i++) + if (aChances[i] <= 0) + aChances[i] = 10000; + for (int i = 0; i < aFluidInputs.length; i++) + aFluidInputs[i] = new GT_FluidStack(aFluidInputs[i]); + for (int i = 0; i < aFluidOutputs.length; i++) + aFluidOutputs[i] = new GT_FluidStack(aFluidOutputs[i]); - for (int i = 0; i < aInputs.length; i++) - if (aInputs[i] != null && Items.feather.getDamage(aInputs[i]) != W) + for (ItemStack aInput : aInputs) + if (aInput != null && Items.feather.getDamage(aInput) != W) for (int j = 0; j < aOutputs.length; j++) { - if (GT_Utility.areStacksEqual(aInputs[i], aOutputs[j])) { - if (aInputs[i].stackSize >= aOutputs[j].stackSize) { - aInputs[i].stackSize -= aOutputs[j].stackSize; + if (GT_Utility.areStacksEqual(aInput, aOutputs[j])) { + if (aInput.stackSize >= aOutputs[j].stackSize) { + aInput.stackSize -= aOutputs[j].stackSize; aOutputs[j] = null; } else { - aOutputs[j].stackSize -= aInputs[i].stackSize; + aOutputs[j].stackSize -= aInput.stackSize; } } } if (aOptimize && aDuration >= 32) { - ArrayList tList = new ArrayList(); + ArrayList tList = new ArrayList<>(); tList.addAll(Arrays.asList(aInputs)); tList.addAll(Arrays.asList(aOutputs)); for (int i = 0; i < tList.size(); i++) if (tList.get(i) == null) tList.remove(i--); @@ -138,16 +149,30 @@ public class GT_Recipe implements Comparable { for (byte i = (byte) Math.min(64, aDuration / 16); i > 1; i--) if (aDuration / i >= 16) { boolean temp = true; - for (int j = 0, k = tList.size(); temp && j < k; j++) - if (tList.get(j).stackSize % i != 0) temp = false; - for (int j = 0; temp && j < aFluidInputs.length; j++) - if (aFluidInputs[j].amount % i != 0) temp = false; - for (int j = 0; temp && j < aFluidOutputs.length; j++) - if (aFluidOutputs[j].amount % i != 0) temp = false; + for (ItemStack stack : tList) + if (stack.stackSize % i != 0) { + temp = false; + break; + } + if (temp) + for (FluidStack aFluidInput : aFluidInputs) + if (aFluidInput.amount % i != 0) { + temp = false; + break; + } + if (temp) + for (FluidStack aFluidOutput : aFluidOutputs) + if (aFluidOutput.amount % i != 0) { + temp = false; + break; + } if (temp) { - for (int j = 0, k = tList.size(); j < k; j++) tList.get(j).stackSize /= i; - for (int j = 0; j < aFluidInputs.length; j++) aFluidInputs[j].amount /= i; - for (int j = 0; j < aFluidOutputs.length; j++) aFluidOutputs[j].amount /= i; + for (ItemStack itemStack : tList) + itemStack.stackSize /= i; + for (FluidStack aFluidInput : aFluidInputs) + aFluidInput.amount /= i; + for (FluidStack aFluidOutput : aFluidOutputs) + aFluidOutput.amount /= i; aDuration /= i; } } @@ -227,7 +252,7 @@ public class GT_Recipe implements Comparable { } public GT_Recipe(ItemStack aInput1, int aInput2, ItemStack aOutput1, ItemStack aOutput2) { - this(true, new ItemStack[]{aInput1, GT_ModHandler.getIC2Item("industrialTnt", aInput2 > 0 ? aInput2 < 64 ? aInput2 : 64 : 1, new ItemStack(Blocks.tnt, aInput2 > 0 ? aInput2 < 64 ? aInput2 : 64 : 1))}, new ItemStack[]{aOutput1, aOutput2}, null, null, null, null, 20, 30, 0); + this(true, new ItemStack[]{aInput1, GT_ModHandler.getIC2Item("industrialTnt", aInput2 > 0 ? Math.min(aInput2, 64) : 1, new ItemStack(Blocks.tnt, aInput2 > 0 ? Math.min(aInput2, 64) : 1))}, new ItemStack[]{aOutput1, aOutput2}, null, null, null, null, 20, 30, 0); if (mInputs.length > 0 && mOutputs[0] != null) { GT_Recipe_Map.sImplosionRecipes.addRecipe(this); } @@ -524,92 +549,92 @@ public class GT_Recipe implements Comparable { /** * Contains all Recipe Maps */ - public static final Collection sMappings = new ArrayList(); - - public static final GT_Recipe_Map sOreWasherRecipes = new GT_Recipe_Map(new HashSet(500), "gt.recipe.orewasher", "Ore Washing Plant", null, RES_PATH_GUI + "basicmachines/OreWasher", 1, 3, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sThermalCentrifugeRecipes = new GT_Recipe_Map(new HashSet(1000), "gt.recipe.thermalcentrifuge", "Thermal Centrifuge", null, RES_PATH_GUI + "basicmachines/ThermalCentrifuge", 1, 3, 1, 0, 2, E, 1, E, true, true); - public static final GT_Recipe_Map sCompressorRecipes = new GT_Recipe_Map(new HashSet(750), "gt.recipe.compressor", "Compressor", null, RES_PATH_GUI + "basicmachines/Compressor", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sExtractorRecipes = new GT_Recipe_Map(new HashSet(250), "gt.recipe.extractor", "Extractor", null, RES_PATH_GUI + "basicmachines/Extractor", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sRecyclerRecipes = new GT_Recipe_Map_Recycler(new HashSet(0), "ic.recipe.recycler", "Recycler", "ic2.recycler", RES_PATH_GUI + "basicmachines/Recycler", 1, 1, 1, 0, 1, E, 1, E, true, false); - public static final GT_Recipe_Map sFurnaceRecipes = new GT_Recipe_Map_Furnace(new HashSet(0), "mc.recipe.furnace", "Furnace", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false); - public static final GT_Recipe_Map sMicrowaveRecipes = new GT_Recipe_Map_Microwave(new HashSet(0), "gt.recipe.microwave", "Microwave", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false); - - public static final GT_Recipe_Map sScannerFakeRecipes = new GT_Recipe_Map(new HashSet(300), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Scanner", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(new HashSet(200), "gt.recipe.rockbreaker", "Rock Breaker", null, RES_PATH_GUI + "basicmachines/RockBreaker", 1, 1, 0, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map(new HashSet(1000), "gt.recipe.byproductlist", "Ore Byproduct List", null, RES_PATH_GUI + "basicmachines/Default", 1, 6, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sReplicatorFakeRecipes = new GT_Recipe_Map(new HashSet(100), "gt.recipe.replicator", "Replicator", null, RES_PATH_GUI + "basicmachines/Replicator", 0, 1, 0, 1, 1, E, 1, E, true, true); - //public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet(30), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sAssemblylineVisualRecipes = new GT_Recipe_Map(new HashSet(110), "gt.recipe.fakeAssemblylineProcess", "Assemblyline Process", null, RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, false); - public static final GT_Recipe_Map sPlasmaArcFurnaceRecipes = new GT_Recipe_Map(new HashSet(20000), "gt.recipe.plasmaarcfurnace", "Plasma Arc Furnace", null, RES_PATH_GUI + "basicmachines/PlasmaArcFurnace", 1, 4, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sArcFurnaceRecipes = new GT_Recipe_Map(new HashSet(20000), "gt.recipe.arcfurnace", "Arc Furnace", null, RES_PATH_GUI + "basicmachines/ArcFurnace", 1, 4, 1, 1, 3, E, 1, E, true, true); - public static final GT_Recipe_Map sPrinterRecipes = new GT_Recipe_Map_Printer(new HashSet(5), "gt.recipe.printer", "Printer", null, RES_PATH_GUI + "basicmachines/Printer", 1, 1, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sSifterRecipes = new GT_Recipe_Map(new HashSet(105), "gt.recipe.sifter", "Sifter", null, RES_PATH_GUI + "basicmachines/Sifter", 1, 9, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sPressRecipes = new GT_Recipe_Map_FormingPress(new HashSet(300), "gt.recipe.press", "Forming Press", null, RES_PATH_GUI + "basicmachines/Press", 2, 1, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sLaserEngraverRecipes = new GT_Recipe_Map(new HashSet(810), "gt.recipe.laserengraver", "Precision Laser Engraver", null, RES_PATH_GUI + "basicmachines/LaserEngraver", 2, 1, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sMixerRecipes = new GT_Recipe_Map(new HashSet(900), "gt.recipe.mixer", "Mixer", null, RES_PATH_GUI + "basicmachines/Mixer2", 9, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sAutoclaveRecipes = new GT_Recipe_Map(new HashSet(300), "gt.recipe.autoclave", "Autoclave", null, RES_PATH_GUI + "basicmachines/Autoclave", 1, 1, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sElectroMagneticSeparatorRecipes = new GT_Recipe_Map(new HashSet(50), "gt.recipe.electromagneticseparator", "Electromagnetic Separator", null, RES_PATH_GUI + "basicmachines/ElectromagneticSeparator", 1, 3, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sPolarizerRecipes = new GT_Recipe_Map(new HashSet(300), "gt.recipe.polarizer", "Electromagnetic Polarizer", null, RES_PATH_GUI + "basicmachines/Polarizer", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sMaceratorRecipes = new GT_Recipe_Map_Macerator(new HashSet(16600), "gt.recipe.macerator", "Pulverization", null, RES_PATH_GUI + "basicmachines/Macerator4", 1, 4, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sChemicalBathRecipes = new GT_Recipe_Map(new HashSet(2550), "gt.recipe.chemicalbath", "Chemical Bath", null, RES_PATH_GUI + "basicmachines/ChemicalBath", 1, 3, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sFluidCannerRecipes = new GT_Recipe_Map_FluidCanner(new HashSet(2100), "gt.recipe.fluidcanner", "Fluid Canning Machine", null, RES_PATH_GUI + "basicmachines/FluidCannerNEI", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sBrewingRecipes = new GT_Recipe_Map(new HashSet(450), "gt.recipe.brewer", "Brewing Machine", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 0, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sFluidHeaterRecipes = new GT_Recipe_Map(new HashSet(10), "gt.recipe.fluidheater", "Fluid Heater", null, RES_PATH_GUI + "basicmachines/FluidHeater", 1, 0, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sDistilleryRecipes = new GT_Recipe_Map(new HashSet(400), "gt.recipe.distillery", "Distillery", null, RES_PATH_GUI + "basicmachines/Distillery", 1, 1, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sFermentingRecipes = new GT_Recipe_Map(new HashSet(50), "gt.recipe.fermenter", "Fermenter", null, RES_PATH_GUI + "basicmachines/Fermenter", 0, 0, 0, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sFluidSolidficationRecipes = new GT_Recipe_Map(new HashSet(35000), "gt.recipe.fluidsolidifier", "Fluid Solidifier", null, RES_PATH_GUI + "basicmachines/FluidSolidifier", 1, 1, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sFluidExtractionRecipes = new GT_Recipe_Map(new HashSet(15000), "gt.recipe.fluidextractor", "Fluid Extractor", null, RES_PATH_GUI + "basicmachines/FluidExtractor", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sBoxinatorRecipes = new GT_Recipe_Map(new HashSet(2500), "gt.recipe.packager", "Packager", null, RES_PATH_GUI + "basicmachines/Packager", 2, 1, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sUnboxinatorRecipes = new GT_Recipe_Map_Unboxinator(new HashSet(2500), "gt.recipe.unpackager", "Unpackager", null, RES_PATH_GUI + "basicmachines/Unpackager", 1, 2, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sFusionRecipes = new GT_Recipe_Map(new HashSet(50), "gt.recipe.fusionreactor", "Fusion Reactor", null, RES_PATH_GUI + "basicmachines/FusionReactor", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true); - public static final GT_Recipe_Map sCentrifugeRecipes = new GT_Recipe_Map(new HashSet(1200), "gt.recipe.centrifuge", "Centrifuge", null, RES_PATH_GUI + "basicmachines/Centrifuge", 2, 6, 0, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sElectrolyzerRecipes = new GT_Recipe_Map(new HashSet(300), "gt.recipe.electrolyzer", "Electrolyzer", null, RES_PATH_GUI + "basicmachines/Electrolyzer", 2, 6, 0, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sBlastRecipes = new GT_Recipe_Map(new HashSet(800), "gt.recipe.blastfurnace", "Blast Furnace", null, RES_PATH_GUI + "basicmachines/Default", 2, 2, 1, 0, 1, "Heat Capacity: ", 1, " K", false, true); - public static final GT_Recipe_Map sPrimitiveBlastRecipes = new GT_Recipe_Map(new HashSet(200), "gt.recipe.primitiveblastfurnace", "Primitive Blast Furnace", null, RES_PATH_GUI + "basicmachines/Default", 3, 3, 1, 0, 1, E, 1, E, false, true); - public static final GT_Recipe_Map sImplosionRecipes = new GT_Recipe_Map(new HashSet(900), "gt.recipe.implosioncompressor", "Implosion Compressor", null, RES_PATH_GUI + "basicmachines/Default", 2, 2, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sVacuumRecipes = new GT_Recipe_Map(new HashSet(305), "gt.recipe.vacuumfreezer", "Vacuum Freezer", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, false, true); - public static final GT_Recipe_Map sChemicalRecipes = new GT_Recipe_Map(new HashSet(1170), "gt.recipe.chemicalreactor", "Chemical Reactor", null, RES_PATH_GUI + "basicmachines/ChemicalReactor", 2, 2, 1, 0, 1, E, 1, E, true, true); + public static final Collection sMappings = new ArrayList<>(); + + public static final GT_Recipe_Map sOreWasherRecipes = new GT_Recipe_Map(new HashSet<>(500), "gt.recipe.orewasher", "Ore Washing Plant", null, RES_PATH_GUI + "basicmachines/OreWasher", 1, 3, 1, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sThermalCentrifugeRecipes = new GT_Recipe_Map(new HashSet<>(1000), "gt.recipe.thermalcentrifuge", "Thermal Centrifuge", null, RES_PATH_GUI + "basicmachines/ThermalCentrifuge", 1, 3, 1, 0, 2, E, 1, E, true, true); + public static final GT_Recipe_Map sCompressorRecipes = new GT_Recipe_Map(new HashSet<>(750), "gt.recipe.compressor", "Compressor", null, RES_PATH_GUI + "basicmachines/Compressor", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sExtractorRecipes = new GT_Recipe_Map(new HashSet<>(250), "gt.recipe.extractor", "Extractor", null, RES_PATH_GUI + "basicmachines/Extractor", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sRecyclerRecipes = new GT_Recipe_Map_Recycler(new HashSet<>(0), "ic.recipe.recycler", "Recycler", "ic2.recycler", RES_PATH_GUI + "basicmachines/Recycler", 1, 1, 1, 0, 1, E, 1, E, true, false); + public static final GT_Recipe_Map sFurnaceRecipes = new GT_Recipe_Map_Furnace(new HashSet<>(0), "mc.recipe.furnace", "Furnace", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false); + public static final GT_Recipe_Map sMicrowaveRecipes = new GT_Recipe_Map_Microwave(new HashSet<>(0), "gt.recipe.microwave", "Microwave", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false); + + public static final GT_Recipe_Map sScannerFakeRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Scanner", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(new HashSet<>(200), "gt.recipe.rockbreaker", "Rock Breaker", null, RES_PATH_GUI + "basicmachines/RockBreaker", 1, 1, 0, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map(new HashSet<>(1000), "gt.recipe.byproductlist", "Ore Byproduct List", null, RES_PATH_GUI + "basicmachines/Default", 1, 6, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sReplicatorFakeRecipes = new GT_Recipe_Map(new HashSet<>(100), "gt.recipe.replicator", "Replicator", null, RES_PATH_GUI + "basicmachines/Replicator", 0, 1, 0, 1, 1, E, 1, E, true, true); + //public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet<>(30), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sAssemblylineVisualRecipes = new GT_Recipe_Map(new HashSet<>(110), "gt.recipe.fakeAssemblylineProcess", "Assemblyline Process", null, RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, false); + public static final GT_Recipe_Map sPlasmaArcFurnaceRecipes = new GT_Recipe_Map(new HashSet<>(20000), "gt.recipe.plasmaarcfurnace", "Plasma Arc Furnace", null, RES_PATH_GUI + "basicmachines/PlasmaArcFurnace", 1, 4, 1, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sArcFurnaceRecipes = new GT_Recipe_Map(new HashSet<>(20000), "gt.recipe.arcfurnace", "Arc Furnace", null, RES_PATH_GUI + "basicmachines/ArcFurnace", 1, 4, 1, 1, 3, E, 1, E, true, true); + public static final GT_Recipe_Map sPrinterRecipes = new GT_Recipe_Map_Printer(new HashSet<>(5), "gt.recipe.printer", "Printer", null, RES_PATH_GUI + "basicmachines/Printer", 1, 1, 1, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sSifterRecipes = new GT_Recipe_Map(new HashSet<>(105), "gt.recipe.sifter", "Sifter", null, RES_PATH_GUI + "basicmachines/Sifter", 1, 9, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sPressRecipes = new GT_Recipe_Map_FormingPress(new HashSet<>(300), "gt.recipe.press", "Forming Press", null, RES_PATH_GUI + "basicmachines/Press", 2, 1, 2, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sLaserEngraverRecipes = new GT_Recipe_Map(new HashSet<>(810), "gt.recipe.laserengraver", "Precision Laser Engraver", null, RES_PATH_GUI + "basicmachines/LaserEngraver", 2, 1, 2, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sMixerRecipes = new GT_Recipe_Map(new HashSet<>(900), "gt.recipe.mixer", "Mixer", null, RES_PATH_GUI + "basicmachines/Mixer2", 9, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sAutoclaveRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.autoclave", "Autoclave", null, RES_PATH_GUI + "basicmachines/Autoclave", 1, 1, 1, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sElectroMagneticSeparatorRecipes = new GT_Recipe_Map(new HashSet<>(50), "gt.recipe.electromagneticseparator", "Electromagnetic Separator", null, RES_PATH_GUI + "basicmachines/ElectromagneticSeparator", 1, 3, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sPolarizerRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.polarizer", "Electromagnetic Polarizer", null, RES_PATH_GUI + "basicmachines/Polarizer", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sMaceratorRecipes = new GT_Recipe_Map_Macerator(new HashSet<>(16600), "gt.recipe.macerator", "Pulverization", null, RES_PATH_GUI + "basicmachines/Macerator4", 1, 4, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sChemicalBathRecipes = new GT_Recipe_Map(new HashSet<>(2550), "gt.recipe.chemicalbath", "Chemical Bath", null, RES_PATH_GUI + "basicmachines/ChemicalBath", 1, 3, 1, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sFluidCannerRecipes = new GT_Recipe_Map_FluidCanner(new HashSet<>(2100), "gt.recipe.fluidcanner", "Fluid Canning Machine", null, RES_PATH_GUI + "basicmachines/FluidCannerNEI", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sBrewingRecipes = new GT_Recipe_Map(new HashSet<>(450), "gt.recipe.brewer", "Brewing Machine", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 0, 1, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sFluidHeaterRecipes = new GT_Recipe_Map(new HashSet<>(10), "gt.recipe.fluidheater", "Fluid Heater", null, RES_PATH_GUI + "basicmachines/FluidHeater", 1, 0, 1, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sDistilleryRecipes = new GT_Recipe_Map(new HashSet<>(400), "gt.recipe.distillery", "Distillery", null, RES_PATH_GUI + "basicmachines/Distillery", 1, 1, 1, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sFermentingRecipes = new GT_Recipe_Map(new HashSet<>(50), "gt.recipe.fermenter", "Fermenter", null, RES_PATH_GUI + "basicmachines/Fermenter", 0, 0, 0, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sFluidSolidficationRecipes = new GT_Recipe_Map(new HashSet<>(35000), "gt.recipe.fluidsolidifier", "Fluid Solidifier", null, RES_PATH_GUI + "basicmachines/FluidSolidifier", 1, 1, 1, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sFluidExtractionRecipes = new GT_Recipe_Map(new HashSet<>(15000), "gt.recipe.fluidextractor", "Fluid Extractor", null, RES_PATH_GUI + "basicmachines/FluidExtractor", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sBoxinatorRecipes = new GT_Recipe_Map(new HashSet<>(2500), "gt.recipe.packager", "Packager", null, RES_PATH_GUI + "basicmachines/Packager", 2, 1, 2, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sUnboxinatorRecipes = new GT_Recipe_Map_Unboxinator(new HashSet<>(2500), "gt.recipe.unpackager", "Unpackager", null, RES_PATH_GUI + "basicmachines/Unpackager", 1, 2, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sFusionRecipes = new GT_Recipe_Map(new HashSet<>(50), "gt.recipe.fusionreactor", "Fusion Reactor", null, RES_PATH_GUI + "basicmachines/FusionReactor", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true); + public static final GT_Recipe_Map sCentrifugeRecipes = new GT_Recipe_Map(new HashSet<>(1200), "gt.recipe.centrifuge", "Centrifuge", null, RES_PATH_GUI + "basicmachines/Centrifuge", 2, 6, 0, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sElectrolyzerRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.electrolyzer", "Electrolyzer", null, RES_PATH_GUI + "basicmachines/Electrolyzer", 2, 6, 0, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sBlastRecipes = new GT_Recipe_Map(new HashSet<>(800), "gt.recipe.blastfurnace", "Blast Furnace", null, RES_PATH_GUI + "basicmachines/Default", 2, 2, 1, 0, 1, "Heat Capacity: ", 1, " K", false, true); + public static final GT_Recipe_Map sPrimitiveBlastRecipes = new GT_Recipe_Map(new HashSet<>(200), "gt.recipe.primitiveblastfurnace", "Primitive Blast Furnace", null, RES_PATH_GUI + "basicmachines/Default", 3, 3, 1, 0, 1, E, 1, E, false, true); + public static final GT_Recipe_Map sImplosionRecipes = new GT_Recipe_Map(new HashSet<>(900), "gt.recipe.implosioncompressor", "Implosion Compressor", null, RES_PATH_GUI + "basicmachines/Default", 2, 2, 2, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sVacuumRecipes = new GT_Recipe_Map(new HashSet<>(305), "gt.recipe.vacuumfreezer", "Vacuum Freezer", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, false, true); + public static final GT_Recipe_Map sChemicalRecipes = new GT_Recipe_Map(new HashSet<>(1170), "gt.recipe.chemicalreactor", "Chemical Reactor", null, RES_PATH_GUI + "basicmachines/ChemicalReactor", 2, 2, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sMultiblockChemicalRecipes = new GT_Recipe_Map_LargeChemicalReactor(); public static final GT_Recipe_Map sDistillationRecipes = new GT_Recipe_Map_DistillationTower(); - public static final GT_Recipe_Map sCrakingRecipes = new GT_Recipe_Map(new HashSet(70), "gt.recipe.craker", "Oil Cracker", null, RES_PATH_GUI + "basicmachines/OilCracker", 1, 1, 1, 2, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sPyrolyseRecipes = new GT_Recipe_Map(new HashSet(150), "gt.recipe.pyro", "Pyrolyse Oven", null, RES_PATH_GUI + "basicmachines/Default", 2, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sWiremillRecipes = new GT_Recipe_Map(new HashSet(450), "gt.recipe.wiremill", "Wiremill", null, RES_PATH_GUI + "basicmachines/Wiremill", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sBenderRecipes = new GT_Recipe_Map(new HashSet(5000), "gt.recipe.metalbender", "Bending Machine", null, RES_PATH_GUI + "basicmachines/Bender", 2, 1, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sAlloySmelterRecipes = new GT_Recipe_Map(new HashSet(12000), "gt.recipe.alloysmelter", "Alloy Smelter", null, RES_PATH_GUI + "basicmachines/AlloySmelter", 2, 1, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet(8200), "gt.recipe.assembler", "Assembler", null, RES_PATH_GUI + "basicmachines/Assembler2", 9, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sCircuitAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet(605), "gt.recipe.circuitassembler", "Circuit Assembler", null, RES_PATH_GUI + "basicmachines/CircuitAssembler", 6, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sCannerRecipes = new GT_Recipe_Map(new HashSet(900), "gt.recipe.canner", "Canning Machine", null, RES_PATH_GUI + "basicmachines/Canner", 2, 2, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sCNCRecipes = new GT_Recipe_Map(new HashSet(100), "gt.recipe.cncmachine", "CNC Machine", null, RES_PATH_GUI + "basicmachines/Default", 2, 1, 2, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sLatheRecipes = new GT_Recipe_Map(new HashSet(1150), "gt.recipe.lathe", "Lathe", null, RES_PATH_GUI + "basicmachines/Lathe", 1, 2, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sCutterRecipes = new GT_Recipe_Map(new HashSet(5125), "gt.recipe.cuttingsaw", "Cutting Machine", null, RES_PATH_GUI + "basicmachines/Cutter2", 2, 2, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sSlicerRecipes = new GT_Recipe_Map(new HashSet(20), "gt.recipe.slicer", "Slicing Machine", null, RES_PATH_GUI + "basicmachines/Slicer", 2, 1, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sExtruderRecipes = new GT_Recipe_Map(new HashSet(13000), "gt.recipe.extruder", "Extruder", null, RES_PATH_GUI + "basicmachines/Extruder", 2, 1, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sHammerRecipes = new GT_Recipe_Map(new HashSet(3800), "gt.recipe.hammer", "Forge Hammer", null, RES_PATH_GUI + "basicmachines/Hammer", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sAmplifiers = new GT_Recipe_Map(new HashSet(2), "gt.recipe.uuamplifier", "Amplifabricator", null, RES_PATH_GUI + "basicmachines/Amplifabricator", 1, 0, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sMassFabFakeRecipes = new GT_Recipe_Map(new HashSet(2), "gt.recipe.massfab", "Mass Fabrication", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 0, 1, 0, 10, E, 1, E, true, true); - public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel(new HashSet(20), "gt.recipe.dieselgeneratorfuel", "Diesel Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sTurbineFuels = new GT_Recipe_Map_Fuel(new HashSet(25), "gt.recipe.gasturbinefuel", "Gas Turbine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sHotFuels = new GT_Recipe_Map_Fuel(new HashSet(10), "gt.recipe.thermalgeneratorfuel", "Thermal Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, false); - public static final GT_Recipe_Map_Fuel sDenseLiquidFuels = new GT_Recipe_Map_Fuel(new HashSet(15), "gt.recipe.semifluidboilerfuels", "Semifluid Boiler Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sPlasmaFuels = new GT_Recipe_Map_Fuel(new HashSet(100), "gt.recipe.plasmageneratorfuels", "Plasma Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sMagicFuels = new GT_Recipe_Map_Fuel(new HashSet(100), "gt.recipe.magicfuels", "Magic Energy Absorber", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sSmallNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet(1), "gt.recipe.smallnaquadahreactor", "Naquadah Reactor MkI", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sLargeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet(1), "gt.recipe.largenaquadahreactor", "Naquadah Reactor MkII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet(1), "gt.recipe.fluidnaquadahreactor", "Naquadah Reactor MkIII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sExtremeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet(1), "gt.recipe.hugenaquadahreactor", "Naquadah Reactor MkIV", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sUltraHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet(1), "gt.recipe.extrahugenaquadahreactor", "Naquadah Reactor MkV", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sFluidNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet(1), "gt.recipe.fluidnaquadahreactor", "Fluid Naquadah Reactor", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map sCrakingRecipes = new GT_Recipe_Map(new HashSet<>(70), "gt.recipe.craker", "Oil Cracker", null, RES_PATH_GUI + "basicmachines/OilCracker", 1, 1, 1, 2, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sPyrolyseRecipes = new GT_Recipe_Map(new HashSet<>(150), "gt.recipe.pyro", "Pyrolyse Oven", null, RES_PATH_GUI + "basicmachines/Default", 2, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sWiremillRecipes = new GT_Recipe_Map(new HashSet<>(450), "gt.recipe.wiremill", "Wiremill", null, RES_PATH_GUI + "basicmachines/Wiremill", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sBenderRecipes = new GT_Recipe_Map(new HashSet<>(5000), "gt.recipe.metalbender", "Bending Machine", null, RES_PATH_GUI + "basicmachines/Bender", 2, 1, 2, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sAlloySmelterRecipes = new GT_Recipe_Map(new HashSet<>(12000), "gt.recipe.alloysmelter", "Alloy Smelter", null, RES_PATH_GUI + "basicmachines/AlloySmelter", 2, 1, 2, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<>(8200), "gt.recipe.assembler", "Assembler", null, RES_PATH_GUI + "basicmachines/Assembler2", 9, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sCircuitAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<>(605), "gt.recipe.circuitassembler", "Circuit Assembler", null, RES_PATH_GUI + "basicmachines/CircuitAssembler", 6, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sCannerRecipes = new GT_Recipe_Map(new HashSet<>(900), "gt.recipe.canner", "Canning Machine", null, RES_PATH_GUI + "basicmachines/Canner", 2, 2, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sCNCRecipes = new GT_Recipe_Map(new HashSet<>(100), "gt.recipe.cncmachine", "CNC Machine", null, RES_PATH_GUI + "basicmachines/Default", 2, 1, 2, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sLatheRecipes = new GT_Recipe_Map(new HashSet<>(1150), "gt.recipe.lathe", "Lathe", null, RES_PATH_GUI + "basicmachines/Lathe", 1, 2, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sCutterRecipes = new GT_Recipe_Map(new HashSet<>(5125), "gt.recipe.cuttingsaw", "Cutting Machine", null, RES_PATH_GUI + "basicmachines/Cutter2", 2, 2, 1, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sSlicerRecipes = new GT_Recipe_Map(new HashSet<>(20), "gt.recipe.slicer", "Slicing Machine", null, RES_PATH_GUI + "basicmachines/Slicer", 2, 1, 2, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sExtruderRecipes = new GT_Recipe_Map(new HashSet<>(13000), "gt.recipe.extruder", "Extruder", null, RES_PATH_GUI + "basicmachines/Extruder", 2, 1, 2, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sHammerRecipes = new GT_Recipe_Map(new HashSet<>(3800), "gt.recipe.hammer", "Forge Hammer", null, RES_PATH_GUI + "basicmachines/Hammer", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sAmplifiers = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.uuamplifier", "Amplifabricator", null, RES_PATH_GUI + "basicmachines/Amplifabricator", 1, 0, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sMassFabFakeRecipes = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.massfab", "Mass Fabrication", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 0, 1, 0, 10, E, 1, E, true, true); + public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.dieselgeneratorfuel", "Diesel Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sTurbineFuels = new GT_Recipe_Map_Fuel(new HashSet<>(25), "gt.recipe.gasturbinefuel", "Gas Turbine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sHotFuels = new GT_Recipe_Map_Fuel(new HashSet<>(10), "gt.recipe.thermalgeneratorfuel", "Thermal Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, false); + public static final GT_Recipe_Map_Fuel sDenseLiquidFuels = new GT_Recipe_Map_Fuel(new HashSet<>(15), "gt.recipe.semifluidboilerfuels", "Semifluid Boiler Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sPlasmaFuels = new GT_Recipe_Map_Fuel(new HashSet<>(100), "gt.recipe.plasmageneratorfuels", "Plasma Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sMagicFuels = new GT_Recipe_Map_Fuel(new HashSet<>(100), "gt.recipe.magicfuels", "Magic Energy Absorber", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sSmallNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.smallnaquadahreactor", "Naquadah Reactor MkI", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sLargeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.largenaquadahreactor", "Naquadah Reactor MkII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.fluidnaquadahreactor", "Naquadah Reactor MkIII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sExtremeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.hugenaquadahreactor", "Naquadah Reactor MkIV", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sUltraHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.extrahugenaquadahreactor", "Naquadah Reactor MkV", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sFluidNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.fluidnaquadahreactor", "Fluid Naquadah Reactor", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_LargeBoilerFakeFuels sLargeBoilerFakeFuels = new GT_Recipe_Map_LargeBoilerFakeFuels(); - + /** * HashMap of Recipes based on their Items */ - public final Map> mRecipeItemMap = new /*Concurrent*/HashMap>(); + public final Map> mRecipeItemMap = new /*Concurrent*/HashMap<>(); /** * HashMap of Recipes based on their Fluids */ - public final Map> mRecipeFluidMap = new /*Concurrent*/HashMap>(); - public final HashSet mRecipeFluidNameMap = new HashSet(); + public final Map> mRecipeFluidMap = new /*Concurrent*/HashMap<>(); + public final HashSet mRecipeFluidNameMap = new HashSet<>(); /** * The List of all Recipes */ @@ -725,22 +750,19 @@ public class GT_Recipe implements Comparable { mRecipeList.add(aRecipe); for (FluidStack aFluid : aRecipe.mFluidInputs) if (aFluid != null) { - Collection tList = mRecipeFluidMap.get(aFluid.getFluid()); - if (tList == null) mRecipeFluidMap.put(aFluid.getFluid(), tList = new HashSet(1)); + Collection tList = mRecipeFluidMap.computeIfAbsent(aFluid.getFluid(), k -> new HashSet<>(1)); tList.add(aRecipe); - if(!mRecipeFluidNameMap.contains(aFluid.getFluid().getName())) - mRecipeFluidNameMap.add(aFluid.getFluid().getName()); + mRecipeFluidNameMap.add(aFluid.getFluid().getName()); } return addToItemMap(aRecipe); } public void reInit() { - Map> tMap = mRecipeItemMap; - if (tMap != null) tMap.clear(); + mRecipeItemMap.clear(); for (GT_Recipe tRecipe : mRecipeList) { GT_OreDictUnificator.setStackArray(true, tRecipe.mInputs); GT_OreDictUnificator.setStackArray(true, tRecipe.mOutputs); - if (tMap != null) addToItemMap(tRecipe); + addToItemMap(tRecipe); } } @@ -819,7 +841,7 @@ public class GT_Recipe implements Comparable { } // Unification happens here in case the Input isn't already unificated. - if (aNotUnificated) aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs); + if (aNotUnificated) aInputs = GT_OreDictUnificator.getStackArray(true, aInputs); // Check the Recipe which has been used last time in order to not have to search for it again, if possible. if (aRecipe != null) @@ -858,8 +880,7 @@ public class GT_Recipe implements Comparable { for (ItemStack aStack : aRecipe.mInputs) if (aStack != null) { GT_ItemStack tStack = new GT_ItemStack(aStack); - Collection tList = mRecipeItemMap.get(tStack); - if (tList == null) mRecipeItemMap.put(tStack, tList = new HashSet(1)); + Collection tList = mRecipeItemMap.computeIfAbsent(tStack, k -> new HashSet<>(1)); tList.add(aRecipe); } return aRecipe; @@ -1300,7 +1321,7 @@ public class GT_Recipe implements Comparable { try { List tRecipeOutputs = mods.railcraft.api.crafting.RailcraftCraftingManager.rockCrusher.getRecipe(GT_Utility.copyAmount(1, aInputs[0])).getRandomizedOuputs(); if (tRecipeOutputs != null) { - aRecipe = new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, tRecipeOutputs.toArray(new ItemStack[tRecipeOutputs.size()]), null, null, null, null, 800, 2, 0); + aRecipe = new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, tRecipeOutputs.toArray(new ItemStack[0]), null, null, null, null, 800, 2, 0); aRecipe.mCanBeBuffered = false; aRecipe.mNeedsEmptyOutput = true; return aRecipe; @@ -1525,31 +1546,31 @@ public class GT_Recipe implements Comparable { public static class GT_Recipe_Map_LargeBoilerFakeFuels extends GT_Recipe_Map { public GT_Recipe_Map_LargeBoilerFakeFuels() { - super(new HashSet(55), "gt.recipe.largeboilerfakefuels", "Large Boiler", null, RES_PATH_GUI + "basicmachines/Default", 1, 0, 1, 0, 1, E, 1, E, true, true); + super(new HashSet<>(55), "gt.recipe.largeboilerfakefuels", "Large Boiler", null, RES_PATH_GUI + "basicmachines/Default", 1, 0, 1, 0, 1, E, 1, E, true, true); GT_Recipe explanatoryRecipe = new GT_Recipe(true, new ItemStack[]{}, new ItemStack[]{}, null, null, null, null, 1, 1, 1); explanatoryRecipe.setNeiDesc("Not all solid fuels are listed.", "Any item that burns in a", "vanilla furnace will burn in", "a Large Boiler."); addRecipe(explanatoryRecipe); } - - public GT_Recipe addDenseLiquidRecipe(GT_Recipe recipe) { - return addRecipe(recipe, ((double)recipe.mSpecialValue) / 10); - } - public GT_Recipe addDieselRecipe(GT_Recipe recipe) { - return addRecipe(recipe,((double)recipe.mSpecialValue) / 40); - } + public GT_Recipe addDenseLiquidRecipe(GT_Recipe recipe) { + return addRecipe(recipe, ((double) recipe.mSpecialValue) / 10); + } - public void addSolidRecipes(ItemStack ... itemStacks) { - for (ItemStack itemStack : itemStacks){ - addSolidRecipe(itemStack); - } - } - - public GT_Recipe addSolidRecipe(ItemStack fuelItemStack){ - return addRecipe(new GT_Recipe(true, new ItemStack[]{fuelItemStack}, new ItemStack[]{}, null, null, null, null, 1, 0, GT_ModHandler.getFuelValue(fuelItemStack) / 1600), ((double)GT_ModHandler.getFuelValue(fuelItemStack)) / 1600); - } - - private GT_Recipe addRecipe(GT_Recipe recipe, double baseBurnTime){ + public GT_Recipe addDieselRecipe(GT_Recipe recipe) { + return addRecipe(recipe, ((double) recipe.mSpecialValue) / 40); + } + + public void addSolidRecipes(ItemStack... itemStacks) { + for (ItemStack itemStack : itemStacks) { + addSolidRecipe(itemStack); + } + } + + public GT_Recipe addSolidRecipe(ItemStack fuelItemStack) { + return addRecipe(new GT_Recipe(true, new ItemStack[]{fuelItemStack}, new ItemStack[]{}, null, null, null, null, 1, 0, GT_ModHandler.getFuelValue(fuelItemStack) / 1600), ((double) GT_ModHandler.getFuelValue(fuelItemStack)) / 1600); + } + + private GT_Recipe addRecipe(GT_Recipe recipe, double baseBurnTime) { recipe = new GT_Recipe(recipe); //Some recipes will have a burn time like 15.9999999 and % always rounds down double floatErrorCorrection = 0.0001; @@ -1579,16 +1600,16 @@ public class GT_Recipe implements Comparable { private static int FLUID_OUTPUT_COUNT = 4; public GT_Recipe_Map_LargeChemicalReactor() { - super(new HashSet(1000), "gt.recipe.largechemicalreactor", "Large Chemical Reactor", null, RES_PATH_GUI + "basicmachines/Default", 2, OUTPUT_COUNT, 0, 0, 1, E, 1, E, true, true); + super(new HashSet<>(1000), "gt.recipe.largechemicalreactor", "Large Chemical Reactor", null, RES_PATH_GUI + "basicmachines/Default", 2, OUTPUT_COUNT, 0, 0, 1, E, 1, E, true, true); } @Override public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - aOptimize = false; - ArrayList adjustedInputs = new ArrayList(); - ArrayList adjustedOutputs = new ArrayList(); - ArrayList adjustedFluidInputs = new ArrayList(); - ArrayList adjustedFluidOutputs = new ArrayList(); + aOptimize = false; + ArrayList adjustedInputs = new ArrayList<>(); + ArrayList adjustedOutputs = new ArrayList<>(); + ArrayList adjustedFluidInputs = new ArrayList<>(); + ArrayList adjustedFluidOutputs = new ArrayList<>(); if (aInputs == null) { aInputs = new ItemStack[0]; @@ -1596,9 +1617,9 @@ public class GT_Recipe implements Comparable { aInputs = GT_Utility.getArrayListWithoutTrailingNulls(aInputs).toArray(new ItemStack[0]); } - for (ItemStack input : aInputs) { - FluidStack inputFluidContent = FluidContainerRegistry.getFluidForFilledItem(input); - if (inputFluidContent != null) { + for (ItemStack input : aInputs) { + FluidStack inputFluidContent = FluidContainerRegistry.getFluidForFilledItem(input); + if (inputFluidContent != null) { inputFluidContent.amount *= input.stackSize; if (inputFluidContent.getFluid().getName().equals("ic2steam")) { inputFluidContent = GT_ModHandler.getSteam(inputFluidContent.amount); @@ -1616,54 +1637,48 @@ public class GT_Recipe implements Comparable { } else { adjustedInputs.add(input); } - } else { - adjustedInputs.add(input); - } - } - } + } else { + adjustedInputs.add(input); + } + } + } if (aFluidInputs == null) { aFluidInputs = new FluidStack[0]; } - } - for (FluidStack fluidInput : aFluidInputs) { - adjustedFluidInputs.add(fluidInput); - } - aInputs = adjustedInputs.toArray(new ItemStack[adjustedInputs.size()]); - aFluidInputs = adjustedFluidInputs.toArray(new FluidStack[adjustedFluidInputs.size()]); + } + Collections.addAll(adjustedFluidInputs, aFluidInputs); + aInputs = adjustedInputs.toArray(new ItemStack[0]); + aFluidInputs = adjustedFluidInputs.toArray(new FluidStack[0]); if (aOutputs == null) { aOutputs = new ItemStack[0]; } else { aOutputs = GT_Utility.getArrayListWithoutTrailingNulls(aOutputs).toArray(new ItemStack[0]); } - - for (ItemStack output : aOutputs) { - FluidStack outputFluidContent = FluidContainerRegistry.getFluidForFilledItem(output); - if (outputFluidContent != null) { + + for (ItemStack output : aOutputs) { + FluidStack outputFluidContent = FluidContainerRegistry.getFluidForFilledItem(output); + if (outputFluidContent != null) { outputFluidContent.amount *= output.stackSize; if (outputFluidContent.getFluid().getName().equals("ic2steam")) { outputFluidContent = GT_ModHandler.getSteam(outputFluidContent.amount); } adjustedFluidOutputs.add(outputFluidContent); - } else { - ItemData itemData = GT_OreDictUnificator.getItemData(output); - if (itemData != null && itemData.hasValidPrefixMaterialData() && itemData.mMaterial.mMaterial == Materials.Empty) { - continue; - } else { - adjustedOutputs.add(output); - } - } - } + } else { + ItemData itemData = GT_OreDictUnificator.getItemData(output); + if (!(itemData != null && itemData.hasValidPrefixMaterialData() && itemData.mMaterial.mMaterial == Materials.Empty)) { + adjustedOutputs.add(output); + } + } + } if (aFluidOutputs == null) { aFluidOutputs = new FluidStack[0]; } - for (FluidStack fluidOutput : aFluidOutputs) { - adjustedFluidOutputs.add(fluidOutput); - } - aOutputs = adjustedOutputs.toArray(new ItemStack[adjustedOutputs.size()]); - aFluidOutputs = adjustedFluidOutputs.toArray(new FluidStack[adjustedFluidOutputs.size()]); - + Collections.addAll(adjustedFluidOutputs, aFluidOutputs); + aOutputs = adjustedOutputs.toArray(new ItemStack[0]); + aFluidOutputs = adjustedFluidOutputs.toArray(new FluidStack[0]); + return addRecipe(new GT_Recipe_LargeChemicalReactor(aOptimize, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); } @@ -1675,15 +1690,15 @@ public class GT_Recipe implements Comparable { @Override public ArrayList getInputPositionedStacks() { - int itemLimit = Math.min(mInputs.length, TOTAL_INPUT_COUNT); - int fluidLimit = Math.min(mFluidInputs.length, TOTAL_INPUT_COUNT - itemLimit); - int inputlimit = itemLimit + fluidLimit; - int j = 0; + int itemLimit = Math.min(mInputs.length, TOTAL_INPUT_COUNT); + int fluidLimit = Math.min(mFluidInputs.length, TOTAL_INPUT_COUNT - itemLimit); + int inputlimit = itemLimit + fluidLimit; + int j = 0; - ArrayList inputStacks = new ArrayList(inputlimit); - - for (int i = 0; i < itemLimit; i++, j++) { - if( this.mInputs == null || (this.mInputs[i] == null && (i == 0 && itemLimit == 1)) ) { + ArrayList inputStacks = new ArrayList<>(inputlimit); + + for (int i = 0; i < itemLimit; i++, j++) { + if (this.mInputs == null || (this.mInputs[i] == null && (i == 0 && itemLimit == 1))) { if (this.mOutputs != null && this.mOutputs.length > 0 && this.mOutputs[0] != null) GT_Log.out.println("recipe " + this.toString() + " Output 0:" + this.mOutputs[0].getDisplayName() + " has errored!"); else @@ -1718,19 +1733,19 @@ public class GT_Recipe implements Comparable { @Override public ArrayList getOutputPositionedStacks() { - int itemLimit = Math.min(mOutputs.length, OUTPUT_COUNT); - int fluidLimit = Math.min(mFluidOutputs.length, FLUID_OUTPUT_COUNT); - ArrayList outputStacks = new ArrayList(itemLimit + fluidLimit); - - for (int i = 0; i < itemLimit; i++) { + int itemLimit = Math.min(mOutputs.length, OUTPUT_COUNT); + int fluidLimit = Math.min(mFluidOutputs.length, FLUID_OUTPUT_COUNT); + ArrayList outputStacks = new ArrayList<>(itemLimit + fluidLimit); + + for (int i = 0; i < itemLimit; i++) { outputStacks.add(new FixedPositionedStack(this.mOutputs[i].copy(), 102 + i * 18, 5)); - } - - for (int i = 0; i < fluidLimit; i++) { - outputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidOutputs[i], true), 102 + i * 18, 23)); - } - - return outputStacks; + } + + for (int i = 0; i < fluidLimit; i++) { + outputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidOutputs[i], true), 102 + i * 18, 23)); + } + + return outputStacks; } @@ -1741,7 +1756,7 @@ public class GT_Recipe implements Comparable { private static final int ROW_SIZE = 3; public GT_Recipe_Map_DistillationTower() { - super(new HashSet(110), "gt.recipe.distillationtower", "Distillation Tower", null, RES_PATH_GUI + "basicmachines/DistillationTower", 2, 4, 0, 0, 1, E, 1, E, true, true); + super(new HashSet<>(110), "gt.recipe.distillationtower", "Distillation Tower", null, RES_PATH_GUI + "basicmachines/DistillationTower", 2, 4, 0, 0, 1, E, 1, E, true, true); } @Override @@ -1761,7 +1776,7 @@ public class GT_Recipe implements Comparable { @Override public ArrayList getInputPositionedStacks() { - ArrayList inputStacks = new ArrayList(1); + ArrayList inputStacks = new ArrayList<>(1); if (this.mFluidInputs.length > 0 && this.mFluidInputs[0] != null) { inputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidInputs[0], true), 48, 52)); @@ -1771,7 +1786,7 @@ public class GT_Recipe implements Comparable { @Override public ArrayList getOutputPositionedStacks() { int fluidLimit = Math.min(mFluidOutputs.length, FLUID_OUTPUT_COUNT); - ArrayList outputStacks = new ArrayList(1 + fluidLimit); + ArrayList outputStacks = new ArrayList<>(1 + fluidLimit); if (this.mOutputs.length > 0 && this.mOutputs[0] != null) { outputStacks.add(new FixedPositionedStack(this.getOutput(0), 102, 52)); -- cgit From bf0f2b3f3ed62076114902c05addb38ca76b92ca Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Sun, 15 Mar 2020 18:02:56 +0100 Subject: Refactored GT_MetaTileEntity_Replicator.java Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> --- .../tileentities/machines/basic/GT_MetaTileEntity_Replicator.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/main') diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java index 7079713acf..1a9b928560 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java @@ -14,9 +14,7 @@ import gregtech.common.items.behaviors.Behaviour_DataOrb; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; public class GT_MetaTileEntity_Replicator extends GT_MetaTileEntity_BasicMachine { @@ -105,10 +103,7 @@ public class GT_MetaTileEntity_Replicator public int getCapacity() { if ((sHeaviestElementMass == 0) && (GregTech_API.sPostloadFinished)) { - Materials tMaterial; - for (Iterator i$ = Arrays.asList(Materials.values()).iterator(); i$.hasNext(); sHeaviestElementMass = Math.max(sHeaviestElementMass, (int) tMaterial.getMass())) { - tMaterial = (Materials) i$.next(); - } + Materials.getMaterialsMap().values().parallelStream().forEach(tMaterial -> sHeaviestElementMass = Math.max(sHeaviestElementMass, (int) tMaterial.getMass())); } return sHeaviestElementMass; } -- cgit