diff options
author | Martin Robertz <dream-master@gmx.net> | 2021-10-21 11:46:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-21 11:46:41 +0200 |
commit | f7aaaa3c5fa83b9fa3252db38ce24a78017b34fe (patch) | |
tree | 4654fb2d78bdda75d23945082292aae3daab2a51 /src/main/java/gregtech/api/util/GT_Recipe.java | |
parent | 44daab3de43d93efc528deece21e15c110e6f5f2 (diff) | |
parent | 0a5c21841fa3eb0ad581173868a06983e0bc0baf (diff) | |
download | GT5-Unofficial-f7aaaa3c5fa83b9fa3252db38ce24a78017b34fe.tar.gz GT5-Unofficial-f7aaaa3c5fa83b9fa3252db38ce24a78017b34fe.tar.bz2 GT5-Unofficial-f7aaaa3c5fa83b9fa3252db38ce24a78017b34fe.zip |
Merge pull request #697 from GTNewHorizons/remember-recipe-map
Make Input Bus and Input Hatch to remember recipe map
Diffstat (limited to 'src/main/java/gregtech/api/util/GT_Recipe.java')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_Recipe.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 6130adfaef..118d1e31a8 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -572,6 +572,10 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Contains all Recipe Maps */ public static final Collection<GT_Recipe_Map> sMappings = new ArrayList<>(); + /** + * All recipe maps indexed by their {@link #mUniqueIdentifier}. + */ + public static final Map<String, GT_Recipe_Map> sIndexedMappings = new HashMap<>(); public static final GT_Recipe_Map sOreWasherRecipes = new GT_Recipe_Map(new HashSet<>(500), "gt.recipe.orewasher", "Ore Washing Plant", null, RES_PATH_GUI + "basicmachines/OreWasher", 1, 3, 1, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map sThermalCentrifugeRecipes = new GT_Recipe_Map(new HashSet<>(1000), "gt.recipe.thermalcentrifuge", "Thermal Centrifuge", null, RES_PATH_GUI + "basicmachines/ThermalCentrifuge", 1, 3, 1, 0, 2, E, 1, E, true, true); @@ -686,6 +690,12 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public final boolean mNEIAllowed, mShowVoltageAmperageInNEI; /** + * Unique identifier for this recipe map. Generated from aUnlocalizedName and a few other parameters. + * See constructor for details. + */ + public final String mUniqueIdentifier; + + /** * Initialises a new type of Recipe Handler. * * @param aRecipeList a List you specify as Recipe List. Usually just an ArrayList with a pre-initialised Size. @@ -717,6 +727,9 @@ public class GT_Recipe implements Comparable<GT_Recipe> { GregTech_API.sFluidMappings.add(mRecipeFluidMap); GregTech_API.sItemStackMappings.add(mRecipeItemMap); GT_LanguageManager.addStringLocalization(mUnlocalizedName = aUnlocalizedName, aLocalName); + mUniqueIdentifier = String.format("%s_%d_%d_%d_%d_%d", aUnlocalizedName, aAmperage, aUsualInputCount, aUsualOutputCount, aMinimalInputFluids, aMinimalInputItems); + if (sIndexedMappings.put(mUniqueIdentifier, this) != null) + throw new IllegalArgumentException("Duplicate recipe map registered: " + mUniqueIdentifier); } public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { |