diff options
Diffstat (limited to 'src/main/java/gregtech/api/util/GTRecipe.java')
-rw-r--r-- | src/main/java/gregtech/api/util/GTRecipe.java | 25 |
1 files changed, 25 insertions, 0 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. |