diff --git a/src/main/java/mezz/jei/recipes/RecipeRegistry.java b/src/main/java/mezz/jei/recipes/RecipeRegistry.java index 5d08d8ea3..43d587a1a 100644 --- a/src/main/java/mezz/jei/recipes/RecipeRegistry.java +++ b/src/main/java/mezz/jei/recipes/RecipeRegistry.java @@ -35,9 +35,11 @@ import mezz.jei.util.Log; import net.minecraft.block.Block; import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.enchantment.EnchantmentData; import net.minecraft.inventory.Container; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemEnchantedBook; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; @@ -540,6 +542,20 @@ public RecipeClickableArea getRecipeClickableArea(GuiContainer gui, int mouseX, return null; } + /** + * Special case for EnchantmentData which replaces enchanted book items. + */ + @Nullable + private static ItemStack getEnchantBookFromEnchantData(IFocus focus) { + Object ingredient = focus.getValue(); + if (ingredient instanceof EnchantmentData) { + EnchantmentData enchantData = (EnchantmentData) ingredient; + return ItemEnchantedBook.getEnchantedItemStack(enchantData); + } + + return null; + } + /** * Special case for ItemBlocks containing fluid blocks. * Nothing crafts those, the player probably wants to look up fluids. @@ -566,6 +582,10 @@ private static FluidStack getFluidFromItemBlock(IFocus focus) { public List getRecipeCategories(IFocus focus) { focus = Focus.check(focus); + ItemStack enchantBook = getEnchantBookFromEnchantData(focus); + if (enchantBook != null) { + return getRecipeCategories(createFocus(focus.getMode(), enchantBook)); + } FluidStack fluidStack = getFluidFromItemBlock(focus); if (fluidStack != null) { return getRecipeCategories(createFocus(focus.getMode(), fluidStack)); @@ -599,6 +619,10 @@ public List getRecipeWrappers(IRecipeCategory