diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-01-06 15:01:10 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-01-06 15:01:10 +0800 |
| commit | 0d8c3fa7d1422067ec3c4a1b2d624db9afb54ab4 (patch) | |
| tree | 27ede6fd331aa9641b3a3d55dddaa084011c2ae2 /src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java | |
| parent | 22494701d3080868d6dbf4d5ae9f4100a5332d9e (diff) | |
| download | RoughlyEnoughItems-0d8c3fa7d1422067ec3c4a1b2d624db9afb54ab4.tar.gz RoughlyEnoughItems-0d8c3fa7d1422067ec3c4a1b2d624db9afb54ab4.tar.bz2 RoughlyEnoughItems-0d8c3fa7d1422067ec3c4a1b2d624db9afb54ab4.zip | |
3.3.4
Diffstat (limited to 'src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java b/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java index bb71355b0..79a34a19f 100644 --- a/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java @@ -18,6 +18,7 @@ import me.shedaniel.rei.gui.PreRecipeViewingScreen; import me.shedaniel.rei.gui.RecipeViewingScreen; import me.shedaniel.rei.gui.VillagerRecipeViewingScreen; import me.shedaniel.rei.gui.config.RecipeScreenType; +import me.shedaniel.rei.utils.CollectionUtils; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.network.ClientSidePacketRegistry; import net.fabricmc.fabric.impl.client.keybinding.KeyBindingRegistryImpl; @@ -171,10 +172,9 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { @Override public boolean executeViewAllRecipesFromCategory(Identifier category) { Map<RecipeCategory<?>, List<RecipeDisplay>> map = Maps.newLinkedHashMap(); - Optional<RecipeCategory<?>> any = RecipeHelper.getInstance().getAllCategories().stream().filter(c -> c.getIdentifier().equals(category)).findAny(); - if (!any.isPresent()) + RecipeCategory<?> recipeCategory = CollectionUtils.findFirstOrNull(RecipeHelper.getInstance().getAllCategories(), c -> c.getIdentifier().equals(category)); + if (recipeCategory == null) return false; - RecipeCategory<?> recipeCategory = any.get(); map.put(recipeCategory, RecipeHelper.getInstance().getAllRecipesFromCategory(recipeCategory)); if (map.keySet().size() > 0) openRecipeViewingScreen(map); @@ -185,10 +185,9 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { public boolean executeViewAllRecipesFromCategories(List<Identifier> categories) { Map<RecipeCategory<?>, List<RecipeDisplay>> map = Maps.newLinkedHashMap(); for (Identifier category : categories) { - Optional<RecipeCategory<?>> any = RecipeHelper.getInstance().getAllCategories().stream().filter(c -> c.getIdentifier().equals(category)).findAny(); - if (!any.isPresent()) + RecipeCategory<?> recipeCategory = CollectionUtils.findFirstOrNull(RecipeHelper.getInstance().getAllCategories(), c -> c.getIdentifier().equals(category)); + if (recipeCategory == null) continue; - RecipeCategory<?> recipeCategory = any.get(); map.put(recipeCategory, RecipeHelper.getInstance().getAllRecipesFromCategory(recipeCategory)); } if (map.keySet().size() > 0) |
