diff options
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r-- | src/main/java/gregtech/api/util/GTRecipe.java | 25 | ||||
-rw-r--r-- | src/main/java/gregtech/api/util/GTRecipeConstants.java | 9 |
2 files changed, 27 insertions, 7 deletions
diff --git a/src/main/java/gregtech/api/util/GTRecipe.java b/src/main/java/gregtech/api/util/GTRecipe.java index d27412d4ec..9f44b56c7a 100644 --- a/src/main/java/gregtech/api/util/GTRecipe.java +++ b/src/main/java/gregtech/api/util/GTRecipe.java @@ -374,6 +374,7 @@ public class GTRecipe implements Comparable<GTRecipe> { map.getBackend() .reInit(); } + RecipeAssemblyLine.reInit(); } public ItemStack getRepresentativeInput(int aIndex) { @@ -945,6 +946,8 @@ public class GTRecipe implements Comparable<GTRecipe> { public ItemStack[][] mOreDictAlt; private int mPersistentHash; + private final List<ItemStack> dataSticksForNEI = new ArrayList<>(); + /** * THIS CONSTRUCTOR DOES SET THE PERSISTENT HASH. * <p> @@ -1102,6 +1105,28 @@ public class GTRecipe implements Comparable<GTRecipe> { } /** + * WARNING: this class will maintain a strong reference over ALL data sticks created this way. DO NOT call this + * methods recklessly as it will cause memory leak! + */ + public ItemStack newDataStickForNEI(String aDisplayName) { + ItemStack dataStick = ItemList.Tool_DataStick.getWithName(1L, aDisplayName); + // we don't actually needs to set the recipe data here. no one will read the recipe data before a world load + // and before a world load id remap will happen and the recipe data will be finally set in the below + // reInit() method + // AssemblyLineUtils.setAssemblyLineRecipeOnDataStick(dataStick, this, false); + dataSticksForNEI.add(dataStick); + return dataStick; + } + + public static void reInit() { + for (RecipeAssemblyLine recipe : sAssemblylineRecipes) { + for (ItemStack stack : recipe.dataSticksForNEI) { + AssemblyLineUtils.setAssemblyLineRecipeOnDataStick(stack, recipe, false); + } + } + } + + /** * @param inputBusses List of input busses to check. * @return An array containing the amount of item to consume from the first slot of every input bus. * {@code null} if at least one item fails to match the recipe ingredient. diff --git a/src/main/java/gregtech/api/util/GTRecipeConstants.java b/src/main/java/gregtech/api/util/GTRecipeConstants.java index d1a9f2c60a..883f1060ac 100644 --- a/src/main/java/gregtech/api/util/GTRecipeConstants.java +++ b/src/main/java/gregtech/api/util/GTRecipeConstants.java @@ -16,7 +16,6 @@ import net.minecraftforge.fluids.FluidStack; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.GTValues; -import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.TierEU; @@ -508,14 +507,12 @@ public class GTRecipeConstants { GTRecipe.RecipeAssemblyLine.sAssemblylineRecipes.add(tRecipe); AssemblyLineUtils.addRecipeToCache(tRecipe); - ItemStack writesDataStick = ItemList.Tool_DataStick.getWithName(1L, "Writes Research result"); - AssemblyLineUtils.setAssemblyLineRecipeOnDataStick(writesDataStick, tRecipe, false); Collection<GTRecipe> ret = new ArrayList<>(3); ret.addAll( GTValues.RA.stdBuilder() .itemInputs(aResearchItem) .itemOutputs(aOutput) - .special(writesDataStick) + .special(tRecipe.newDataStickForNEI("Writes Research result")) .duration(aResearchTime) .eut(TierEU.RECIPE_LV) .specialValue(-201) // means it's scanned @@ -524,14 +521,12 @@ public class GTRecipeConstants { .fake() .addTo(scannerFakeRecipes)); - ItemStack readsDataStick = ItemList.Tool_DataStick.getWithName(1L, "Reads Research result"); - AssemblyLineUtils.setAssemblyLineRecipeOnDataStick(readsDataStick, tRecipe, false); ret.add( RecipeMaps.assemblylineVisualRecipes.addFakeRecipe( false, r.mInputs, new ItemStack[] { aOutput }, - new ItemStack[] { readsDataStick }, + new ItemStack[] { tRecipe.newDataStickForNEI("Reads Research result") }, r.mFluidInputs, null, r.mDuration, |