aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java
index b423bfa91e..bf10b93ce8 100644
--- a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java
+++ b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java
@@ -19,9 +19,13 @@ import scala.actors.threadpool.Arrays;
public class GT_AssemblyLineUtils {
/**
- * A cache of
+ * A cache of Recipes using the Output as Key.
*/
private static HashMap<GT_ItemStack, GT_Recipe_AssemblyLine> sRecipeCacheByOutput = new HashMap<GT_ItemStack, GT_Recipe_AssemblyLine>();
+ /**
+ * A cache of Recipes using the Recipe Hash String as Key.
+ */
+ private static HashMap<String, GT_Recipe_AssemblyLine> sRecipeCacheByRecipeHash = new HashMap<String, GT_Recipe_AssemblyLine>();
/**
* Checks the DataStick for deprecated/invalid recipes, updating them as required.
@@ -63,6 +67,14 @@ public class GT_AssemblyLineUtils {
if (aTag == null) {
return null;
}
+
+ //Get From Cache
+ if (doesDataStickHaveRecipeHash(aDataStick)) {
+ GT_Recipe_AssemblyLine aRecipeFromCache = sRecipeCacheByRecipeHash.get(getHashFromDataStack(aDataStick));
+ if (aRecipeFromCache != null) {
+ return aRecipeFromCache;
+ }
+ }
for (int i = 0; i < 15; i++) {
int count = aTag.getInteger("a" + i);
@@ -131,7 +143,11 @@ public class GT_AssemblyLineUtils {
for (GT_Recipe_AssemblyLine aRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) {
if (aRecipe.mEUt == aEU && aRecipe.mDuration == aTime) {
if (GT_Utility.areStacksEqual(aOutputs[0], aRecipe.mOutput, true)) {
- if (Arrays.equals(aRecipe.mInputs, aInputs) && Arrays.equals(aRecipe.mFluidInputs, aFluidInputs)) {
+ if (Arrays.equals(aRecipe.mInputs, aInputs) && Arrays.equals(aRecipe.mFluidInputs, aFluidInputs)) {
+ // Cache it
+ String aRecipeHash = generateRecipeHash(aRecipe);
+ sRecipeCacheByRecipeHash.put(aRecipeHash, aRecipe);
+ sRecipeCacheByOutput.put(new GT_ItemStack(aRecipe.mOutput), aRecipe);
return aRecipe;
}
}
@@ -165,6 +181,7 @@ public class GT_AssemblyLineUtils {
if (GT_Utility.areStacksEqual(aRecipeOutput, aOutput)) {
// Cache it to prevent future iterations of all recipes
sRecipeCacheByOutput.put(aCacheStack, aRecipe);
+ sRecipeCacheByRecipeHash.put(generateRecipeHash(aRecipe), aRecipe);
return aRecipe;
}
}