diff options
| author | Unknown <shekwancheung0528@gmail.com> | 2019-01-11 12:09:50 +0800 |
|---|---|---|
| committer | Unknown <shekwancheung0528@gmail.com> | 2019-01-11 12:09:50 +0800 |
| commit | def24dd1d0ebd6e12a3a459ece05c0fc94aae4de (patch) | |
| tree | 0472186115f5da4d53c953daf0df6858e03d1a82 /src/main/java/me/shedaniel/rei/client/RecipeHelper.java | |
| parent | ff3c2799a766babb69d772f15958d7a0bf50868c (diff) | |
| download | RoughlyEnoughItems-def24dd1d0ebd6e12a3a459ece05c0fc94aae4de.tar.gz RoughlyEnoughItems-def24dd1d0ebd6e12a3a459ece05c0fc94aae4de.tar.bz2 RoughlyEnoughItems-def24dd1d0ebd6e12a3a459ece05c0fc94aae4de.zip | |
Tabs & Item Usages
Diffstat (limited to 'src/main/java/me/shedaniel/rei/client/RecipeHelper.java')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/client/RecipeHelper.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/java/me/shedaniel/rei/client/RecipeHelper.java b/src/main/java/me/shedaniel/rei/client/RecipeHelper.java index 74780846c..ead30fdfa 100644 --- a/src/main/java/me/shedaniel/rei/client/RecipeHelper.java +++ b/src/main/java/me/shedaniel/rei/client/RecipeHelper.java @@ -86,6 +86,33 @@ public class RecipeHelper implements RecipeSync { return recipeManager; } + public static Map<IRecipeCategory, List<IRecipeDisplay>> getUsagesFor(ItemStack stack) { + Map<Identifier, List<IRecipeDisplay>> categoriesMap = new HashMap<>(); + categories.forEach(f -> categoriesMap.put(f.getIdentifier(), new LinkedList<>())); + for(List<IRecipeDisplay> value : recipeCategoryListMap.values()) + for(IRecipeDisplay recipeDisplay : value) { + boolean found = false; + for(List<ItemStack> input : (List<List<ItemStack>>) recipeDisplay.getInput()) { + for(ItemStack itemStack : input) { + if (ItemStack.areEqualIgnoreTags(itemStack, stack)) { + categoriesMap.get(recipeDisplay.getRecipeCategory()).add(recipeDisplay); + if (found) + break; + } + } + if (found) + break; + } + } + categoriesMap.keySet().removeIf(f -> categoriesMap.get(f).isEmpty()); + Map<IRecipeCategory, List<IRecipeDisplay>> recipeCategoryListMap = Maps.newHashMap(); + categories.forEach(category -> { + if (categoriesMap.containsKey(category.getIdentifier())) + recipeCategoryListMap.put(category, categoriesMap.get(category.getIdentifier())); + }); + return recipeCategoryListMap; + } + @Override public void recipesLoaded(RecipeManager recipeManager) { this.recipeManager = recipeManager; |
