diff options
| author | Unknown <shekwancheung0528@gmail.com> | 2019-06-02 19:41:28 +0800 |
|---|---|---|
| committer | Unknown <shekwancheung0528@gmail.com> | 2019-06-02 19:41:28 +0800 |
| commit | d414c887e0c42325cf2e7c778b32e3fb13ee2e69 (patch) | |
| tree | 7f8a3c76d1171664f7ad79d715f1a749f531f38e /src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java | |
| parent | 6352ba7abe3a01b694b01e03238b297eef447df4 (diff) | |
| download | RoughlyEnoughItems-d414c887e0c42325cf2e7c778b32e3fb13ee2e69.tar.gz RoughlyEnoughItems-d414c887e0c42325cf2e7c778b32e3fb13ee2e69.tar.bz2 RoughlyEnoughItems-d414c887e0c42325cf2e7c778b32e3fb13ee2e69.zip | |
2.9.2 Live Generated Recipe Displays
Diffstat (limited to 'src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java b/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java index 5b22482e9..f7891670f 100644 --- a/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java @@ -42,6 +42,7 @@ public class RecipeHelperImpl implements RecipeHelper { private final Map<Identifier, ButtonAreaSupplier> speedCraftAreaSupplierMap = Maps.newHashMap(); private final Map<Identifier, List<SpeedCraftFunctional>> speedCraftFunctionalMap = Maps.newHashMap(); private final List<DisplayVisibilityHandler> displayVisibilityHandlers = Lists.newArrayList(); + private final List<LiveRecipeGenerator> liveRecipeGenerators = Lists.newArrayList(); private RecipeManager recipeManager; @Override @@ -100,6 +101,8 @@ public class RecipeHelperImpl implements RecipeHelper { if (category.checkTags() ? ItemStack.areEqual(stack, outputStack) : ItemStack.areEqualIgnoreTags(stack, outputStack)) categoriesMap.get(recipeDisplay.getRecipeCategory()).add(recipeDisplay); } + for(LiveRecipeGenerator liveRecipeGenerator : liveRecipeGenerators) + ((Optional<List>) liveRecipeGenerator.getRecipeFor(stack)).ifPresent(o -> categoriesMap.get(liveRecipeGenerator.getCategoryIdentifier()).addAll(o)); Map<RecipeCategory, List<RecipeDisplay>> recipeCategoryListMap = Maps.newLinkedHashMap(); categories.forEach(category -> { if (categoriesMap.containsKey(category.getIdentifier()) && !categoriesMap.get(category.getIdentifier()).isEmpty()) @@ -141,6 +144,8 @@ public class RecipeHelperImpl implements RecipeHelper { } } } + for(LiveRecipeGenerator liveRecipeGenerator : liveRecipeGenerators) + ((Optional<List>) liveRecipeGenerator.getUsageFor(stack)).ifPresent(o -> categoriesMap.get(liveRecipeGenerator.getCategoryIdentifier()).addAll(o)); Map<RecipeCategory, List<RecipeDisplay>> recipeCategoryListMap = Maps.newLinkedHashMap(); categories.forEach(category -> { if (categoriesMap.containsKey(category.getIdentifier()) && !categoriesMap.get(category.getIdentifier()).isEmpty()) @@ -198,6 +203,7 @@ public class RecipeHelperImpl implements RecipeHelper { this.speedCraftFunctionalMap.clear(); this.categoryDisplaySettingsMap.clear(); this.displayVisibilityHandlers.clear(); + this.liveRecipeGenerators.clear(); ((DisplayHelperImpl) RoughlyEnoughItemsCore.getDisplayHelper()).resetCache(); BaseBoundsHandler baseBoundsHandler = new BaseBoundsHandlerImpl(); RoughlyEnoughItemsCore.getDisplayHelper().registerBoundsHandler(baseBoundsHandler); @@ -302,4 +308,9 @@ public class RecipeHelperImpl implements RecipeHelper { return categoryDisplaySettingsMap.entrySet().stream().filter(entry -> entry.getKey().equals(category)).map(Map.Entry::getValue).findAny(); } + @Override + public void registerLiveRecipeGenerator(LiveRecipeGenerator liveRecipeGenerator) { + liveRecipeGenerators.add(liveRecipeGenerator); + } + } |
