diff options
author | Dream-Master <dream-master@gmx.net> | 2020-04-06 23:59:42 +0200 |
---|---|---|
committer | Dream-Master <dream-master@gmx.net> | 2020-04-06 23:59:42 +0200 |
commit | 6319dacc31e3fe6e2286a305515392a9b6c313e8 (patch) | |
tree | 8f343c3651710e4b1d5444454458724323cdedce /src/main/java/gregtech/api/util | |
parent | 018903ff3d872a0a1a39d99cb4259fe3dc98bce3 (diff) | |
download | GT5-Unofficial-6319dacc31e3fe6e2286a305515392a9b6c313e8.tar.gz GT5-Unofficial-6319dacc31e3fe6e2286a305515392a9b6c313e8.tar.bz2 GT5-Unofficial-6319dacc31e3fe6e2286a305515392a9b6c313e8.zip |
Added a better way for the Processing Array to handle recipes.
https://github.com/Blood-Asp/GT5-Unofficial/pull/1551
add missing Packer machines back
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java b/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java new file mode 100644 index 0000000000..e25a0209d9 --- /dev/null +++ b/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java @@ -0,0 +1,31 @@ +package gregtech.api.util; + +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; + +import java.util.HashMap; + +public class GT_ProcessingArray_Manager { + + private static final HashMap<Integer, String> mMetaKeyMap = new HashMap<Integer, String>(); + private static final HashMap<String, GT_Recipe_Map> mRecipeCache = new HashMap<String, GT_Recipe_Map>(); + + public static boolean registerRecipeMapForMeta(int aMeta, GT_Recipe_Map aMap) { + if (aMeta < 0 || aMeta > Short.MAX_VALUE || aMap == null) { + return false; + } + if (mMetaKeyMap.containsKey(aMeta)) { + return false; + } + String aMapNameKey = aMap.mUnlocalizedName; + mMetaKeyMap.put(aMeta, aMapNameKey); + if (!mRecipeCache.containsKey(aMapNameKey)) { + mRecipeCache.put(aMapNameKey, aMap); + } + return true; + } + + public static GT_Recipe_Map getRecipeMapForMeta(int aMeta) { + return mRecipeCache.get(mMetaKeyMap.get(aMeta)); + } + +}
\ No newline at end of file |