From 9f5a9eae9a7863412cc5eb433bf15e5ee71da616 Mon Sep 17 00:00:00 2001 From: Danielshe Date: Sun, 3 Nov 2019 14:44:52 +0800 Subject: 3.2.1 --- .../java/me/shedaniel/rei/api/RecipeHelper.java | 35 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'src/main/java/me/shedaniel/rei/api/RecipeHelper.java') diff --git a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java index 3ef78f603..9c66a6eb4 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java @@ -7,12 +7,14 @@ package me.shedaniel.rei.api; import me.shedaniel.math.api.Rectangle; import me.shedaniel.rei.RoughlyEnoughItemsCore; +import me.shedaniel.rei.api.annotations.ToBeRemoved; import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen; import net.minecraft.item.ItemStack; import net.minecraft.recipe.Recipe; import net.minecraft.recipe.RecipeManager; import net.minecraft.util.Identifier; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -50,7 +52,22 @@ public interface RecipeHelper { * @param inventoryItems the materials * @return the list of craftable items */ - List findCraftableByItems(List inventoryItems); + default List findCraftableByItems(List inventoryItems) { + List itemStacks = new ArrayList<>(); + for (EntryStack item : findCraftableEntriesByItems(inventoryItems)) { + if (item.getItemStack() != null) + itemStacks.add(item.getItemStack()); + } + return itemStacks; + } + + /** + * Gets all craftable items from materials. + * + * @param inventoryItems the materials + * @return the list of craftable entries + */ + List findCraftableEntriesByItems(List inventoryItems); /** * Registers a category @@ -91,7 +108,13 @@ public interface RecipeHelper { * @param stack the stack to be crafted * @return the map of recipes */ - Map, List> getRecipesFor(ItemStack stack); + Map, List> getRecipesFor(EntryStack stack); + + @ToBeRemoved + @Deprecated + default Map, List> getRecipesFor(ItemStack stack) { + return getRecipesFor(EntryStack.create(stack)); + } RecipeCategory getCategory(Identifier identifier); @@ -115,7 +138,13 @@ public interface RecipeHelper { * @param stack the stack to be used * @return the map of recipes */ - Map, List> getUsagesFor(ItemStack stack); + Map, List> getUsagesFor(EntryStack stack); + + @ToBeRemoved + @Deprecated + default Map, List> getUsagesFor(ItemStack stack) { + return getUsagesFor(EntryStack.create(stack)); + } /** * Gets the optional of the speed crafting button area from a category -- cgit