From 0d8c3fa7d1422067ec3c4a1b2d624db9afb54ab4 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Mon, 6 Jan 2020 15:01:10 +0800 Subject: 3.3.4 --- src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java') 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, List> map = Maps.newLinkedHashMap(); - Optional> 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 categories) { Map, List> map = Maps.newLinkedHashMap(); for (Identifier category : categories) { - Optional> 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) -- cgit