From 6319dacc31e3fe6e2286a305515392a9b6c313e8 Mon Sep 17 00:00:00 2001 From: Dream-Master Date: Mon, 6 Apr 2020 23:59:42 +0200 Subject: 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 --- .../api/util/GT_ProcessingArray_Manager.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java (limited to 'src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java') 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 mMetaKeyMap = new HashMap(); + private static final HashMap mRecipeCache = new HashMap(); + + 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 -- cgit