diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 44cd386c..5e6136b8 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -459,7 +459,10 @@ public class GT_Mod FMLLog.info("If your Log stops here, you were too impatient. Wait a bit more next time, before killing Minecraft with the Task Manager.", new Object[0]); gregtechproxy.activateOreDictHandler(); FMLLog.info("Congratulations, you have been waiting long enough. Have a Cake.", new Object[0]); - GT_Log.out.println("GT_Mod: " + GT_ModHandler.sSingleNonBlockDamagableRecipeList.size() + " Recipes were left unused."); + 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); if (GT_Values.D1) { IRecipe tRecipe; for (Iterator i$ = GT_ModHandler.sSingleNonBlockDamagableRecipeList.iterator(); i$.hasNext(); GT_Log.out.println("=> " + tRecipe.getRecipeOutput().getDisplayName())) { diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index 8162360f..a8c9eeea 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -52,7 +52,7 @@ import static gregtech.api.enums.GT_Values.*; public class GT_ModHandler { public static final List sSingleNonBlockDamagableRecipeList = new ArrayList(1000); private static final Map sIC2ItemMap = new HashMap(); - private static final List sAllRecipeList = Collections.synchronizedList(new ArrayList(5000)), sBufferRecipeList = new ArrayList(1000); + private static final List sAllRecipeList = /*Collections.synchronizedList(*/new ArrayList(5000)/*)*/, sBufferRecipeList = new ArrayList(1000); public static volatile int VERSION = 509; public static Collection sNativeRecipeClasses = new HashSet(), sSpecialRecipeClasses = new HashSet(); public static GT_HashSet sNonReplaceableItems = new GT_HashSet(); @@ -64,6 +64,62 @@ public class GT_ModHandler { private static Map sThermalCentrifugeRecipes = new HashMap(); private static Map sMassfabRecipes = new HashMap(); private static boolean sBufferCraftingRecipes = true; + public static List sSingleNonBlockDamagableRecipeList_list = new ArrayList(100); + private static boolean sSingleNonBlockDamagableRecipeList_create = true; + private static final ItemStack sMt1 = new ItemStack(Blocks.dirt, 1, 0), sMt2 = new ItemStack(Blocks.dirt, 1, 0); + private static final String s_H = "h", s_F = "f", s_I = "I", s_P = "P", s_R = "R"; + private static final ItemStack[][] + sShapes1 = new ItemStack[][]{ + {sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1, null}, + {sMt1, null, sMt1, sMt1, null, sMt1, sMt1, sMt1, sMt1}, + {null, sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1}, + {sMt1, sMt1, sMt1, sMt1, null, sMt1, null, null, null}, + {sMt1, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1}, + {sMt1, sMt1, sMt1, sMt1, null, sMt1, sMt1, null, sMt1}, + {null, null, null, sMt1, null, sMt1, sMt1, null, sMt1}, + {null, sMt1, null, null, sMt1, null, null, sMt2, null}, + {sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2, null}, + {null, sMt1, null, null, sMt2, null, null, sMt2, null}, + {sMt1, sMt1, null, sMt1, sMt2, null, null, sMt2, null}, + {null, sMt1, sMt1, null, sMt2, sMt1, null, sMt2, null}, + {sMt1, sMt1, null, null, sMt2, null, null, sMt2, null}, + {null, sMt1, sMt1, null, sMt2, null, null, sMt2, null}, + {null, sMt1, null, sMt1, null, null, null, sMt1, sMt2}, + {null, sMt1, null, null, null, sMt1, sMt2, sMt1, null}, + {null, sMt1, null, sMt1, null, sMt1, null, null, sMt2}, + {null, sMt1, null, sMt1, null, sMt1, sMt2, null, null}, + {null, sMt2, null, null, sMt1, null, null, sMt1, null}, + {null, sMt2, null, null, sMt2, null, sMt1, sMt1, sMt1}, + {null, sMt2, null, null, sMt2, null, null, sMt1, null}, + {null, sMt2, null, sMt1, sMt2, null, sMt1, sMt1, null}, + {null, sMt2, null, null, sMt2, sMt1, null, sMt1, sMt1}, + {null, sMt2, null, null, sMt2, null, sMt1, sMt1, null}, + {sMt1, null, null, null, sMt2, null, null, null, sMt2}, + {null, null, sMt1, null, sMt2, null, sMt2, null, null}, + {sMt1, null, null, null, sMt2, null, null, null, null}, + {null, null, sMt1, null, sMt2, null, null, null, null}, + {sMt1, sMt2, null, null, null, null, null, null, null}, + {sMt2, sMt1, null, null, null, null, null, null, null}, + {sMt1, null, null, sMt2, null, null, null, null, null}, + {sMt2, null, null, sMt1, null, null, null, null, null}, + {sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, null, sMt2, null}, + {sMt1, sMt1, null, sMt1, sMt1, sMt2, sMt1, sMt1, null}, + {null, sMt1, sMt1, sMt2, sMt1, sMt1, null, sMt1, sMt1}, + {null, sMt2, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1}, + {sMt1, sMt1, sMt1, sMt1, sMt2, sMt1, null, sMt2, null}, + {sMt1, sMt1, null, sMt1, sMt2, sMt2, sMt1, sMt1, null}, + {null, sMt1, sMt1, sMt2, sMt2, sMt1, null, sMt1, sMt1}, + {null, sMt2, null, sMt1, sMt2, sMt1, sMt1, sMt1, sMt1}, + {sMt1, null, null, null, sMt1, null, null, null, null}, + {null, sMt1, null, sMt1, null, null, null, null, null}, + {sMt1, sMt1, null, sMt2, null, sMt1, sMt2, null, null}, + {null, sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2} + }; + public static List sSingleNonBlockDamagableRecipeList_validsShapes1 = new ArrayList(44); + public static boolean sSingleNonBlockDamagableRecipeList_validsShapes1_update = false; + public static List sSingleNonBlockDamagableRecipeList_warntOutput = new ArrayList(50); + public static List sVanillaRecipeList_warntOutput = new ArrayList(50); + public static final List sSingleNonBlockDamagableRecipeList_verified = new ArrayList(1000); static { sNativeRecipeClasses.add(ShapedRecipes.class.getName()); @@ -696,7 +752,7 @@ public class GT_ModHandler { public static void stopBufferingCraftingRecipes() { sBufferCraftingRecipes = false; - for (IRecipe tRecipe : sBufferRecipeList) GameRegistry.addRecipe(tRecipe); + for (IRecipe tRecipe : sBufferRecipeList) {GameRegistry.addRecipe(tRecipe);} sBufferRecipeList.clear(); } @@ -1026,11 +1082,11 @@ public class GT_ModHandler { } else if (tObject instanceof String) { tRecipe[i] = GT_OreDictUnificator.getFirstOre(tObject, 1); if (tRecipe[i] == null) break; - } else if (tObject instanceof Boolean) { + }/* else if (tObject instanceof Boolean) { // } else { throw new IllegalArgumentException(); - } + }*/ i++; } removeRecipe(tRecipe); @@ -1260,9 +1316,11 @@ public class GT_ModHandler { * This also removes old Recipes from the List. */ public static ArrayList getVanillyToolRecipeOutputs(ItemStack... aRecipe) { - if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) - sSingleNonBlockDamagableRecipeList.clear(); - if (sSingleNonBlockDamagableRecipeList.isEmpty()) { + ArrayList rList = new ArrayList(); + if (aRecipe == null) {return rList;} + if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) { + sSingleNonBlockDamagableRecipeList.clear();sSingleNonBlockDamagableRecipeList_create = true;sSingleNonBlockDamagableRecipeList_validsShapes1.clear();} + if (sSingleNonBlockDamagableRecipeList_create/*sSingleNonBlockDamagableRecipeList.isEmpty()*/) { for (IRecipe tRecipe : (ArrayList) CraftingManager.getInstance().getRecipeList()) { ItemStack tStack = tRecipe.getRecipeOutput(); if (GT_Utility.isStackValid(tStack) && tStack.getMaxStackSize() == 1 && tStack.getMaxDamage() > 0 && !(tStack.getItem() instanceof ItemBlock) && !(tStack.getItem() instanceof IReactorComponent) && !isElectricItem(tStack) && !GT_Utility.isStackInList(tStack, sNonReplaceableItems)) { @@ -1297,10 +1355,29 @@ public class GT_ModHandler { } } GT_Log.out.println("GT_Mod: Created a List of Tool Recipes containing " + sSingleNonBlockDamagableRecipeList.size() + " Recipes for recycling." + (sSingleNonBlockDamagableRecipeList.size() > 1024 ? " Scanning all these Recipes is the reason for the startup Lag you receive right now." : E)); + int aList_move = sSingleNonBlockDamagableRecipeList.size(); + sSingleNonBlockDamagableRecipeList_list.add(aList_move); + sSingleNonBlockDamagableRecipeList_create = false; + sSingleNonBlockDamagableRecipeList_validsShapes1_update = true; + InventoryCrafting aCrafting = new InventoryCrafting(new Container() { + @Override + public boolean canInteractWith(EntityPlayer var1) {return false;}}, 3, 3); + for (int i = 0; i < aList_move; i++) { + for (int j = 0; j < sShapes1.length; j++) { + ItemStack[] sRecipe = sShapes1[j]; + for (int l = 0; l < 9 && l < sRecipe.length; l++) {aCrafting.setInventorySlotContents(l, sRecipe[l]);} + IRecipe vRecipe = sSingleNonBlockDamagableRecipeList.get(i); + if (vRecipe.matches(aCrafting, DW)) { + if (!(sSingleNonBlockDamagableRecipeList_validsShapes1.contains(j))) {sSingleNonBlockDamagableRecipeList_validsShapes1.add(j);} + sSingleNonBlockDamagableRecipeList_verified.add(vRecipe); + } + } + } } - ArrayList rList = getRecipeOutputs(sSingleNonBlockDamagableRecipeList, true, aRecipe); - if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) - sSingleNonBlockDamagableRecipeList.clear(); + /*ArrayList */ + if (sSingleNonBlockDamagableRecipeList_verified.size() != 0) {rList = getRecipeOutputs(sSingleNonBlockDamagableRecipeList_verified, true, aRecipe);} + if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) { + sSingleNonBlockDamagableRecipeList.clear();sSingleNonBlockDamagableRecipeList_create = true;sSingleNonBlockDamagableRecipeList_validsShapes1.clear();} return rList; } @@ -1318,7 +1395,7 @@ public class GT_ModHandler { */ public static ArrayList getRecipeOutputs(List aList, boolean aDeleteFromList, ItemStack... aRecipe) { ArrayList rList = new ArrayList(); - if (aRecipe == null) return rList; + if (aRecipe == null || aList.size() == 0) return rList; boolean temp = false; for (byte i = 0; i < aRecipe.length; i++) { if (aRecipe[i] != null) { @@ -1333,24 +1410,44 @@ public class GT_ModHandler { return false; } }, 3, 3); - for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]); + for (int i = 0; i < 9 && i < aRecipe.length; i++) {aCrafting.setInventorySlotContents(i, aRecipe[i]);} int aList_sS=aList.size(); - try { - for (int i = 0; i < aList_sS; i++) { - temp = false; - temp = aList.get(i).matches(aCrafting, DW); - if (temp) { - ItemStack tOutput = aList.get(i).getCraftingResult(aCrafting); - if (tOutput == null || tOutput.stackSize <= 0) { - // Seriously, who would ever do that shit? - if (!GregTech_API.sPostloadFinished) - throw new GT_ItsNotMyFaultException("Seems another Mod added a Crafting Recipe with null Output. Tell the Developer of said Mod to fix that."); - } else { - rList.add(GT_Utility.copy(tOutput)); - if (aDeleteFromList) aList.remove(i--); aList_sS=aList.size(); + ArrayList tempaList_list = new ArrayList(); + if(!aDeleteFromList) { + for (int i = 0; i < aList_sS; i++) { + IRecipe tempALg0 = aList.get(i); + if (tempALg0.matches(aCrafting, DW)) { + ItemStack tOutput = tempALg0.getCraftingResult(aCrafting); + if (tOutput == null || tOutput.stackSize <= 0) { + if (!(sVanillaRecipeList_warntOutput.contains(i))) {sVanillaRecipeList_warntOutput.add(i);} + } else { + rList.add(GT_Utility.copy(tOutput)); + if (aDeleteFromList) {tempaList_list.add(i);} + } } } - }} catch (Throwable e) {e.printStackTrace(GT_Log.err);} + } else { + for (int i = 0; i < aList_sS; i++) { + IRecipe tempALg0 = aList.get(i); + ItemStack tOutput = tempALg0.getCraftingResult(aCrafting); + if (tOutput == null || tOutput.stackSize <= 0) { + if (!(sSingleNonBlockDamagableRecipeList_warntOutput.contains(i))) {sSingleNonBlockDamagableRecipeList_warntOutput.add(i);} + } else { + rList.add(GT_Utility.copy(tOutput)); + if (aDeleteFromList) {tempaList_list.add(i);} + } + } + } + //boolean tempaList_list_b = tempaList_list.size() != 0 ? true : false; + if (aDeleteFromList && tempaList_list.size() != 0) { + List tempaList_2 = new ArrayList(); + for (int i = 0; i < aList_sS; i++) { + int k = 0, l = 0; + if (tempaList_list.get(k) == i) {k++;continue;} + tempaList_2.add(aList.get(l));l++; + } + aList = tempaList_2; + } return rList; } diff --git a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java index 611c8d34..27d3aed1 100644 --- a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java +++ b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java @@ -121,6 +121,8 @@ public class GT_RecipeRegistrator { {"Scythe", s_H + s_P + s_I, s_P + s_F + s_R, " " + " " + s_R} }; public static volatile int VERSION = 509; + public static int sRodMaterialList_cycles = 0; + private static int i_count = 0; public static void registerMaterialRecycling(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByproduct) { if (GT_Utility.isStackInvalid(aStack)) return; @@ -272,7 +274,7 @@ public class GT_RecipeRegistrator { * You give this Function a Material and it will scan almost everything for adding recycling Recipes * * @param aMat a Material, for example an Ingot or a Gem. - * @param aOutput the Dust you usually get from macerating aMat + * @param aPlate the Dust you usually get from macerating aMat * @param aRecipeReplacing allows to replace the Recipe with a Plate variant */ public static synchronized void registerUsagesForMaterials(ItemStack aMat, String aPlate, boolean aRecipeReplacing) { @@ -280,8 +282,11 @@ public class GT_RecipeRegistrator { aMat = GT_Utility.copy(aMat); ItemStack tStack; ItemData aItemData = GT_OreDictUnificator.getItemData(aMat); - if (aItemData == null || aItemData.mPrefix != OrePrefixes.ingot) aPlate = null; + boolean aItemData_b_0 = aItemData != null ? true : false; + if (!aItemData_b_0 || aItemData.mPrefix != OrePrefixes.ingot) {aPlate = null;} if (aPlate != null && GT_OreDictUnificator.getFirstOre(aPlate, 1) == null) aPlate = null; + boolean aItemData_b_1 = aItemData.hasValidPrefixMaterialData() ? true : false; + boolean aPlate_b_0 = aPlate != null ? true : false; sMt1.func_150996_a(aMat.getItem()); sMt1.stackSize = 1; @@ -296,12 +301,13 @@ public class GT_RecipeRegistrator { for (ItemStack tMat : tRecipe) { if (tMat == sMt1) tAmount1++; } - if (aItemData != null && aItemData.hasValidPrefixMaterialData()) + if (aItemData_b_0 && aItemData_b_1) for (ItemStack tCrafted : GT_ModHandler.getRecipeOutputs(tRecipe)) { GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1)); } } + GT_ModHandler.getVanillyToolRecipeOutputs(sShapes1[0]); for (Materials tMaterial : sRodMaterialList) { ItemStack tMt2 = GT_OreDictUnificator.get(OrePrefixes.stick, tMaterial, 1); if (tMt2 != null) { @@ -309,37 +315,48 @@ public class GT_RecipeRegistrator { sMt2.stackSize = 1; Items.feather.setDamage(sMt2, Items.feather.getDamage(tMt2)); - for (int i = 0; i < sShapes1.length; i++) { - ItemStack[] tRecipe = sShapes1[i]; + if (GT_ModHandler.sSingleNonBlockDamagableRecipeList.size() == 0 || GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.size() == 0 || GT_ModHandler.sSingleNonBlockDamagableRecipeList_verified.size() == 0) { sRodMaterialList_cycles++;continue;} + int sShapes1_len = GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.size(); + for (int i = 0; i < sShapes1_len; i++) { + int i2 = GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.get(i); + ItemStack[] tRecipe = sShapes1[i2]; + if (tRecipe == null) continue; int tAmount1 = 0, tAmount2 = 0; for (ItemStack tMat : tRecipe) { if (tMat == sMt1) tAmount1++; if (tMat == sMt2) tAmount2++; } - for (ItemStack tCrafted : GT_ModHandler.getVanillyToolRecipeOutputs(tRecipe)) { - if (aItemData != null && aItemData.hasValidPrefixMaterialData()) - GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1, new MaterialStack(tMaterial, OrePrefixes.stick.mMaterialAmount * tAmount2))); + List tempTest = GT_ModHandler.getVanillyToolRecipeOutputs(tRecipe); + if (GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1_update && GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.size() != 0) {sShapes1_len = GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.size();GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1_update = false;} + int tempTest_size_sS = tempTest.size(); + if (tempTest_size_sS > 0) { + for (ItemStack tCrafted : tempTest/*GT_ModHandler.getVanillyToolRecipeOutputs(tRecipe)*/) { + if (aItemData_b_0 && aItemData_b_1) { + GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1, new MaterialStack(tMaterial, OrePrefixes.stick.mMaterialAmount * tAmount2))); + } - if (aRecipeReplacing && aPlate != null && sShapesA[i] != null && sShapesA[i].length > 1) { - assert aItemData != null; - if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.recipereplacements, aItemData.mMaterial.mMaterial + "." + sShapesA[i][0], true)) { - if (null != (tStack = GT_ModHandler.removeRecipe(tRecipe))) { - switch (sShapesA[i].length) { - case 2: - GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); - break; - case 3: - GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], sShapesA[i][2], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); - break; - default: - GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], sShapesA[i][2], sShapesA[i][3], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); - break; + if (aRecipeReplacing && aPlate_b_0 && sShapesA[i2] != null && sShapesA[i2].length > 1) { + //assert aItemData != null;//dead dev code or decomp JAD? + if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.recipereplacements, new StringBuilder().append(aItemData.mMaterial.mMaterial).append('.').append(sShapesA[i2][0]).toString(), true)) { + if (null != (tStack = GT_ModHandler.removeRecipe(tRecipe))) { + switch (sShapesA[i].length) { + case 2: + GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i2][1], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); + break; + case 3: + GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i2][1], sShapesA[i2][2], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); + break; + default: + GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i2][1], sShapesA[i2][2], sShapesA[i2][3], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); + break; + } } } } } } + sRodMaterialList_cycles++; } } }