-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1551 from draknyte1/Fix-Shitty-PA-Handling
Added a better way for the Processing Array to handle recipes. Now addons can register machines to the PA.
- Loading branch information
Showing
5 changed files
with
197 additions
and
177 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package gregtech.api.util; | ||
|
||
import java.util.HashMap; | ||
|
||
import gregtech.api.util.GT_Recipe.GT_Recipe_Map; | ||
|
||
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)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.