aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r--src/main/java/gregtech/api/util/GT_LanguageManager.java4
-rw-r--r--src/main/java/gregtech/api/util/GT_ModHandler.java242
-rw-r--r--src/main/java/gregtech/api/util/GT_OreDictUnificator.java12
-rw-r--r--src/main/java/gregtech/api/util/GT_RecipeRegistrator.java4
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java17
5 files changed, 81 insertions, 198 deletions
diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java
index a60189ea71..9937d0c069 100644
--- a/src/main/java/gregtech/api/util/GT_LanguageManager.java
+++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java
@@ -75,9 +75,11 @@ public class GT_LanguageManager {
public static String getTranslation(String aKey, String aSeperator) {
if (aKey == null) return E;
String rTranslation = E;
+ StringBuilder rTranslationSB = new StringBuilder(rTranslation);
for (String tString : aKey.split(aSeperator)) {
- rTranslation += getTranslation(tString);
+ rTranslationSB.append(getTranslation(tString));
}
+ rTranslation = String.valueOf(rTranslationSB);
return rTranslation;
}
diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java
index 05205cfb97..25992d2739 100644
--- a/src/main/java/gregtech/api/util/GT_ModHandler.java
+++ b/src/main/java/gregtech/api/util/GT_ModHandler.java
@@ -1,9 +1,7 @@
package gregtech.api.util;
-import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.registry.GameRegistry;
-import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.enums.*;
import gregtech.api.interfaces.IDamagableItem;
@@ -39,8 +37,6 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.util.*;
import java.util.Map.Entry;
@@ -56,74 +52,18 @@ import static gregtech.api.enums.GT_Values.*;
public class GT_ModHandler {
public static final List<IRecipe> sSingleNonBlockDamagableRecipeList = new ArrayList<IRecipe>(1000);
private static final Map<String, ItemStack> sIC2ItemMap = new HashMap<String, ItemStack>();
- private static final List<IRecipe> sAllRecipeList = /*Collections.synchronizedList(*/new ArrayList<IRecipe>(5000)/*)*/, sBufferRecipeList = new ArrayList<IRecipe>(1000);
+ private static final List<IRecipe> sAllRecipeList = Collections.synchronizedList(new ArrayList<IRecipe>(5000)), sBufferRecipeList = new ArrayList<IRecipe>(1000);
public static volatile int VERSION = 509;
public static Collection<String> sNativeRecipeClasses = new HashSet<String>(), sSpecialRecipeClasses = new HashSet<String>();
public static GT_HashSet<GT_ItemStack> sNonReplaceableItems = new GT_HashSet<GT_ItemStack>();
public static Object sBoxableWrapper = GT_Utility.callConstructor("gregtechmod.api.util.GT_IBoxableWrapper", 0, null, false);
- private static Map<IRecipeInput, RecipeOutput> sExtractorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
- private static Map<IRecipeInput, RecipeOutput> sMaceratorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
- private static Map<IRecipeInput, RecipeOutput> sCompressorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
- private static Map<IRecipeInput, RecipeOutput> sOreWashingRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
- private static Map<IRecipeInput, RecipeOutput> sThermalCentrifugeRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
- private static Map<IRecipeInput, RecipeOutput> sMassfabRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sExtractorRecipes = new HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sMaceratorRecipes = new HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sCompressorRecipes = new HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sOreWashingRecipes = new HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sThermalCentrifugeRecipes = new HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sMassfabRecipes = new HashMap<IRecipeInput, RecipeOutput>();
private static boolean sBufferCraftingRecipes = true;
- public static List<Integer> sSingleNonBlockDamagableRecipeList_list = new ArrayList<Integer>(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<Integer> sSingleNonBlockDamagableRecipeList_validsShapes1 = new ArrayList<Integer>(44);
- public static boolean sSingleNonBlockDamagableRecipeList_validsShapes1_update = false;
- public static List<Integer> sSingleNonBlockDamagableRecipeList_warntOutput = new ArrayList<Integer>(50);
- public static List<Integer> sVanillaRecipeList_warntOutput = new ArrayList<Integer>(50);
- public static final List<IRecipe> sSingleNonBlockDamagableRecipeList_verified = new ArrayList<IRecipe>(1000);
static {
sNativeRecipeClasses.add(ShapedRecipes.class.getName());
@@ -559,7 +499,7 @@ public class GT_ModHandler {
if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.maceration, aInput, true)) {
GT_Utility.addSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null, aOutput1);
}
- addMagneticraftRecipe(aInput, aOutput1, aOutput2, aChance2, aOutput3, aChance3);
+
RA.addPulveriserRecipe(aInput, new ItemStack[]{aOutput1, aOutput2, aOutput3}, new int[]{10000, aChance2 <= 0 ? 1000 : 100 * aChance2, aChance3 <= 0 ? 1000 : 100 * aChance3}, 400, 2);
if (!OrePrefixes.log.contains(aInput)) {
@@ -593,31 +533,6 @@ public class GT_ModHandler {
}
}
return true;
- }
-
- static Class tClass;
- static Method tMethod1;
- static Method tMethod2;
-
- public static boolean addMagneticraftRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance2, ItemStack aOutput3, int aChance3){
- if(GT_Mod.gregtechproxy.mMagneticraftRecipes && Loader.isModLoaded("Magneticraft")){
- try {
- if(tClass==null)tClass = Class.forName("com.cout970.magneticraft.api.access.MgRecipeRegister");
- if(tMethod1==null)tMethod1 = tClass.getMethod("registerCrusherRecipe", ItemStack.class, ItemStack.class,ItemStack.class, float.class, ItemStack.class, float.class);
- if(tMethod2==null)tMethod2 = tClass.getMethod("registerGrinderRecipe", ItemStack.class, ItemStack.class,ItemStack.class, float.class, ItemStack.class, float.class);
-
- ItemData tData = GT_OreDictUnificator.getAssociation(aInput);
- if(tData!=null&&tData.mPrefix!=null){
- if(tData.mPrefix==OrePrefixes.ore||tData.mPrefix==OrePrefixes.oreBlackgranite||tData.mPrefix==OrePrefixes.oreEndstone||tData.mPrefix==OrePrefixes.oreNetherrack||tData.mPrefix==OrePrefixes.oreRedgranite){
- tMethod1.invoke(null, aInput, aOutput1, aOutput2,(float)((float)aChance2/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent), aOutput3,(float)((float)aChance3/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent));
- }else if(tData.mPrefix==OrePrefixes.crushed||tData.mPrefix==OrePrefixes.crushedCentrifuged||tData.mPrefix==OrePrefixes.crushedPurified){
- tMethod2.invoke(null, aInput, aOutput1, aOutput2,(float)((float)aChance2/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent), aOutput3,(float)((float)aChance3/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent));
- }
- }
-
- } catch (Exception e) {e.printStackTrace();}
- }
- return true;
}
/**
@@ -781,7 +696,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();
}
@@ -950,8 +865,8 @@ public class GT_ModHandler {
if (aRecipe[idx] instanceof Boolean) {
idx++;
}
- /*ConcurrentHash*/Map<Character, ItemStack> tItemStackMap = new /*ConcurrentHash*/HashMap<Character, ItemStack>();
- /*ConcurrentHash*/Map<Character, ItemData> tItemDataMap = new /*ConcurrentHash*/HashMap<Character, ItemData>();
+ HashMap<Character, ItemStack> tItemStackMap = new HashMap<Character, ItemStack>();
+ HashMap<Character, ItemData> tItemDataMap = new HashMap<Character, ItemData>();
tItemStackMap.put(' ', null);
boolean tRemoveRecipe = true;
@@ -1036,12 +951,11 @@ public class GT_ModHandler {
if (aOnlyAddIfThereIsAnyRecipeOutputtingThis && !tThereWasARecipe) {
ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList();
- int tList_sS=tList.size();
- for (int i = 0; i < tList_sS && !tThereWasARecipe; i++) {
+ for (int i = 0; i < tList.size() && !tThereWasARecipe; i++) {
IRecipe tRecipe = tList.get(i);
if (sSpecialRecipeClasses.contains(tRecipe.getClass().getName())) continue;
if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tRecipe.getRecipeOutput()), aResult, true)) {
- tList.remove(i--); tList_sS=tList.size();
+ tList.remove(i--);
tThereWasARecipe = true;
}
}
@@ -1111,11 +1025,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);
@@ -1177,16 +1091,18 @@ public class GT_ModHandler {
}, 3, 3);
for (int i = 0; i < aRecipe.length && i < 9; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]);
ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList();
- int tList_sS=tList.size();
- try {
- for (int i = 0; i < tList_sS; i++) {
- for (; i < tList_sS; i++) {
+ for (int i = 0; i < tList.size(); i++) {
+ try {
+ for (; i < tList.size(); i++) {
if ((!(tList.get(i) instanceof IGT_CraftingRecipe) || ((IGT_CraftingRecipe) tList.get(i)).isRemovable()) && tList.get(i).matches(aCrafting, DW)) {
rReturn = tList.get(i).getCraftingResult(aCrafting);
- if (rReturn != null) tList.remove(i--); tList_sS=tList.size();
+ if (rReturn != null) tList.remove(i--);
}
}
- }} catch (Throwable e) {e.printStackTrace(GT_Log.err);}
+ } catch (Throwable e) {
+ e.printStackTrace(GT_Log.err);
+ }
+ }
return rReturn;
}
@@ -1205,8 +1121,7 @@ public class GT_ModHandler {
boolean rReturn = false;
ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList();
aOutput = GT_OreDictUnificator.get(aOutput);
- int tList_sS=tList.size();
- for (int i = 0; i < tList_sS; i++) {
+ for (int i = 0; i < tList.size(); i++) {
IRecipe tRecipe = tList.get(i);
if (aNotRemoveShapelessRecipes && (tRecipe instanceof ShapelessRecipes || tRecipe instanceof ShapelessOreRecipe))
continue;
@@ -1217,7 +1132,7 @@ public class GT_ModHandler {
}
ItemStack tStack = tRecipe.getRecipeOutput();
if ((!(tRecipe instanceof IGT_CraftingRecipe) || ((IGT_CraftingRecipe) tRecipe).isRemovable()) && GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tStack), aOutput, aIgnoreNBT)) {
- tList.remove(i--); tList_sS=tList.size();
+ tList.remove(i--);
rReturn = true;
}
}
@@ -1254,12 +1169,11 @@ public class GT_ModHandler {
sAllRecipeList.clear();
sAllRecipeList.addAll(tList);
}
- int sAllRecipeList_sS=sAllRecipeList.size();
- for (int i = 0, j = sAllRecipeList_sS; i < j; i++) {
+ for (int i = 0, j = sAllRecipeList.size(); i < j; i++) {
IRecipe tRecipe = sAllRecipeList.get(i);
if (tRecipe.matches(aCrafting, aWorld)) {
if (i > 10) {
- sAllRecipeList.remove(i); sAllRecipeList_sS=sAllRecipeList.size();
+ sAllRecipeList.remove(i);
sAllRecipeList.add(i - 10, tRecipe);
}
return tRecipe.getCraftingResult(aCrafting);
@@ -1319,11 +1233,13 @@ public class GT_ModHandler {
}, 3, 3);
for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]);
ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList();
- int tList_sS=tList.size();
- try {
- for (int i = 0; i < tList_sS; i++) {
+ for (int i = 0; i < tList.size(); i++) {
temp = false;
- temp = tList.get(i).matches(aCrafting, DW);
+ try {
+ temp = tList.get(i).matches(aCrafting, DW);
+ } catch (Throwable e) {
+ e.printStackTrace(GT_Log.err);
+ }
if (temp) {
ItemStack tOutput = aUncopiedStack ? tList.get(i).getRecipeOutput() : tList.get(i).getCraftingResult(aCrafting);
if (tOutput == null || tOutput.stackSize <= 0) {
@@ -1335,7 +1251,7 @@ public class GT_ModHandler {
return GT_Utility.copy(tOutput);
}
}
- }} catch (Throwable e) {e.printStackTrace(GT_Log.err);}
+ }
return null;
}
@@ -1345,17 +1261,15 @@ public class GT_ModHandler {
* This also removes old Recipes from the List.
*/
public static ArrayList<ItemStack> getVanillyToolRecipeOutputs(ItemStack... aRecipe) {
- ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
- 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()*/) {
+ if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished)
+ sSingleNonBlockDamagableRecipeList.clear();
+ if (sSingleNonBlockDamagableRecipeList.isEmpty()) {
for (IRecipe tRecipe : (ArrayList<IRecipe>) 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)) {
if (tRecipe instanceof ShapedOreRecipe) {
boolean temp = true;
- for (Object tObject : ((ShapedOreRecipe) tRecipe).getInput()) {
+ for (Object tObject : ((ShapedOreRecipe) tRecipe).getInput())
if (tObject != null) {
if (tObject instanceof ItemStack && (((ItemStack) tObject).getItem() == null || ((ItemStack) tObject).getMaxStackSize() < 2 || ((ItemStack) tObject).getMaxDamage() > 0 || ((ItemStack) tObject).getItem() instanceof ItemBlock)) {
temp = false;
@@ -1366,8 +1280,7 @@ public class GT_ModHandler {
break;
}
}
- }
- if (temp) {sSingleNonBlockDamagableRecipeList.add(tRecipe);}
+ if (temp) sSingleNonBlockDamagableRecipeList.add(tRecipe);
} else if (tRecipe instanceof ShapedRecipes) {
boolean temp = true;
for (ItemStack tObject : ((ShapedRecipes) tRecipe).recipeItems) {
@@ -1376,36 +1289,17 @@ public class GT_ModHandler {
break;
}
}
- if (temp) {sSingleNonBlockDamagableRecipeList.add(tRecipe);}
+ if (temp) sSingleNonBlockDamagableRecipeList.add(tRecipe);
} else {
sSingleNonBlockDamagableRecipeList.add(tRecipe);
}
}
}
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<ItemStack> */
- 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();}
+ ArrayList<ItemStack> rList = getRecipeOutputs(sSingleNonBlockDamagableRecipeList, true, aRecipe);
+ if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished)
+ sSingleNonBlockDamagableRecipeList.clear();
return rList;
}
@@ -1423,7 +1317,7 @@ public class GT_ModHandler {
*/
public static ArrayList<ItemStack> getRecipeOutputs(List<IRecipe> aList, boolean aDeleteFromList, ItemStack... aRecipe) {
ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
- if (aRecipe == null || aList.size() == 0) {return rList;}
+ if (aRecipe == null) return rList;
boolean temp = false;
for (byte i = 0; i < aRecipe.length; i++) {
if (aRecipe[i] != null) {
@@ -1431,50 +1325,32 @@ public class GT_ModHandler {
break;
}
}
- if (!temp) {return rList;}
+ if (!temp) return rList;
InventoryCrafting aCrafting = new InventoryCrafting(new Container() {
@Override
public boolean canInteractWith(EntityPlayer var1) {
return false;
}
}, 3, 3);
- for (int i = 0; i < 9 && i < aRecipe.length; i++) {aCrafting.setInventorySlotContents(i, aRecipe[i]);}
- int aList_sS=aList.size();
- ArrayList<Integer> tempaList_list = new ArrayList<Integer>();
- 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);}
- }
- }
+ for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]);
+ for (int i = 0; i < aList.size(); i++) {
+ temp = false;
+ try {
+ temp = aList.get(i).matches(aCrafting, DW);
+ } 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 (temp) {
+ ItemStack tOutput = aList.get(i).getCraftingResult(aCrafting);
if (tOutput == null || tOutput.stackSize <= 0) {
- if (!(sSingleNonBlockDamagableRecipeList_warntOutput.contains(i))) {sSingleNonBlockDamagableRecipeList_warntOutput.add(i);}
+ // 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) {tempaList_list.add(i);}
- }
+ if (aDeleteFromList) aList.remove(i--);
}
}
- //boolean tempaList_list_b = tempaList_list.size() != 0 ? true : false;
- if (aDeleteFromList && tempaList_list.size() != 0) {
- List<IRecipe> tempaList_2 = new ArrayList<IRecipe>();
- 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;
}
@@ -1525,7 +1401,7 @@ public class GT_ModHandler {
for (Entry<IRecipeInput, RecipeOutput> tEntry : aRecipeList.entrySet()) {
if (tEntry.getKey().matches(aInput)) {
if (tEntry.getKey().getAmount() <= aInput.stackSize) {
- ItemStack[] tList = (ItemStack[]) tEntry.getValue().items.toArray();
+ ItemStack[] tList = (ItemStack[]) tEntry.getValue().items.toArray(new ItemStack[tEntry.getValue().items.size()]);
if (tList.length == 0) break;
ItemStack[] rList = new ItemStack[aOutputSlots.length];
rRecipeMetaData.setTag("return", tEntry.getValue().metadata);
diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
index dddf2ec576..c8d95140a2 100644
--- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
+++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
@@ -260,12 +260,14 @@ public class GT_OreDictUnificator {
public static ItemStack getGem(Materials aMaterial, long aMaterialAmount) {
ItemStack rStack = null;
- if (((aMaterialAmount >= M) || aMaterialAmount >= M * 32))
+ if (((aMaterialAmount >= M)))
rStack = get(OrePrefixes.gem, aMaterial, aMaterialAmount / M);
- if (rStack == null && (((aMaterialAmount * 2) % M == 0) || aMaterialAmount >= M * 16))
- rStack = get(OrePrefixes.gemFlawed, aMaterial, (aMaterialAmount * 2) / M);
- if (rStack == null && (((aMaterialAmount * 4) >= M)))
- rStack = get(OrePrefixes.gemChipped, aMaterial, (aMaterialAmount * 4) / M);
+ if (rStack == null) {
+ if ((((aMaterialAmount * 2) % M == 0) || aMaterialAmount >= M * 16))
+ rStack = get(OrePrefixes.gemFlawed, aMaterial, (aMaterialAmount * 2) / M);
+ if ((((aMaterialAmount * 4) >= M)))
+ rStack = get(OrePrefixes.gemChipped, aMaterial, (aMaterialAmount * 4) / M);
+ }
return rStack;
}
diff --git a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java
index 0c05e5738a..df26dce0d4 100644
--- a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java
+++ b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java
@@ -178,7 +178,7 @@ public class GT_RecipeRegistrator {
}
public static void registerReverseArcSmelting(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByProduct01, MaterialStack aByProduct02, MaterialStack aByProduct03) {
- registerReverseArcSmelting(aStack, new ItemData(aMaterial == null ? null : new MaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03));
+ registerReverseArcSmelting(aStack, new ItemData(new MaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03));
}
public static void registerReverseArcSmelting(ItemStack aStack, ItemData aData) {
@@ -240,7 +240,7 @@ public class GT_RecipeRegistrator {
}
public static void registerReverseMacerating(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByProduct01, MaterialStack aByProduct02, MaterialStack aByProduct03, boolean aAllowHammer) {
- registerReverseMacerating(aStack, new ItemData(aMaterial == null ? null : new MaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03), aAllowHammer);
+ registerReverseMacerating(aStack, new ItemData(new MaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03), aAllowHammer);
}
public static void registerReverseMacerating(ItemStack aStack, ItemData aData, boolean aAllowHammer) {
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index 309dc47889..34ef3d0963 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -920,7 +920,7 @@ public class GT_Utility {
}
public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, double aX, double aY, double aZ) {
- return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, 0.9F + new Random().nextFloat() * 0.2F, aX, aY, aZ);
+ return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, 1.01818028F, aX, aY, aZ);
}
public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, float aSoundModulation, double aX, double aY, double aZ) {
@@ -1094,7 +1094,6 @@ public class GT_Utility {
* Converts a Number to a String
*/
public static String parseNumberToString(int aNumber) {
- String tString = E;
boolean temp = true, negative = false;
if (aNumber < 0) {
@@ -1102,15 +1101,18 @@ public class GT_Utility {
negative = true;
}
+ StringBuilder tStringB = new StringBuilder();
for (int i = 1000000000; i > 0; i /= 10) {
int tDigit = (aNumber / i) % 10;
if (temp && tDigit != 0) temp = false;
if (!temp) {
- tString += tDigit;
- if (i != 1) for (int j = i; j > 0; j /= 1000) if (j == 1) tString += ",";
+ tStringB.append(tDigit);
+ if (i != 1) for (int j = i; j > 0; j /= 1000) if (j == 1) tStringB.append(",");
}
}
+ String tString = tStringB.toString();
+
if (tString.equals(E)) tString = "0";
return negative ? "-" + tString : tString;
@@ -1409,7 +1411,7 @@ public class GT_Utility {
Collections.sort(tEntrySet, new Comparator<Map.Entry<X, Y>>() {
@Override
public int compare(Entry<X, Y> aValue1, Entry<X, Y> aValue2) {
- return -aValue1.getValue().compareTo(aValue2.getValue());
+ return aValue2.getValue().compareTo(aValue1.getValue());//FB: RV - RV_NEGATING_RESULT_OF_COMPARETO
}
});
LinkedHashMap<X, Y> rMap = new LinkedHashMap<X, Y>();
@@ -1721,10 +1723,11 @@ public class GT_Utility {
+ " Humidity: " + ((ic2.api.crops.ICropTile) tTileEntity).getHumidity()
+ " Air-Quality: " + ((ic2.api.crops.ICropTile) tTileEntity).getAirQuality()
);
- String tString = E;
+ StringBuilder tStringB = new StringBuilder();
for (String tAttribute : ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].attributes()) {
- tString += ", " + tAttribute;
+ tStringB.append(", ").append(tAttribute);
}
+ String tString = tStringB.toString();
tList.add("Attributes:" + tString.replaceFirst(",", E));
tList.add("Discovered by: " + ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].discoveredBy());
}