JEI Utilities

JEI Utilities

2M Downloads

Rare crash when clicking bookmarked item

talchas opened this issue ยท 3 comments

commented

Very rarely when clicking a bookmarked item to see the recipe (and having bookmarked it using this mod's specific-recipe saving feature), I get this crash:

[15:25:28] [Client thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.client.event.GuiScreenEvent$MouseInputEvent$Pre@281348d4:
java.lang.ClassCastException: com.github.vfyjxf.jeiutilities.jei.ingredient.RecipeInfo cannot be cast to net.minecraft.item.ItemStack
	at mezz.jei.plugins.vanilla.ingredients.item.ItemStackHelper.translateFocus(ItemStackHelper.java:43) ~[ItemStackHelper.class:?]
	at com.github.vfyjxf.jeiutilities.jei.ingredient.RecipeInfoHelper.translateFocus(RecipeInfoHelper.java:75) ~[RecipeInfoHelper.class:?]
	at mezz.jei.gui.recipes.RecipeGuiLogic.setFocus(RecipeGuiLogic.java:51) ~[RecipeGuiLogic.class:?]
	at mezz.jei.gui.recipes.RecipesGui.show(RecipesGui.java:407) ~[RecipesGui.class:?]
	at mezz.jei.input.InputHandler.handleMouseClickedFocus(InputHandler.java:180) ~[InputHandler.class:?]
	at mezz.jei.input.InputHandler.handleMouseClick(InputHandler.java:133) ~[InputHandler.class:?]
	at mezz.jei.input.InputHandler.handleMouseEvent(InputHandler.java:102) ~[InputHandler.class:?]
	at mezz.jei.input.InputHandler.onGuiMouseEvent(InputHandler.java:90) ~[InputHandler.class:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_1694_InputHandler_onGuiMouseEvent_Pre.invoke(.dynamic) ~[?:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [EventBus.class:?]
	at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:500) [blk.class:?]
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:1759) [bib.class:?]
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1098) [bib.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:3611) [bib.class:?]
	at net.minecraft.client.main.Main.main(SourceFile:123) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_332]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_332]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_332]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_332]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at org.prismlauncher.launcher.impl.StandardLauncher.launch(StandardLauncher.java:88) [NewLaunch.jar:?]
	at org.prismlauncher.EntryPoint.listen(EntryPoint.java:126) [NewLaunch.jar:?]
	at org.prismlauncher.EntryPoint.main(EntryPoint.java:71) [NewLaunch.jar:?]

This has been while playing https://www.curseforge.com/minecraft/modpacks/nomi-ceu 1.4.3, so JEI-Utilities 0.2.10, and the "jei" is HadEnoughItems 4.23.0.

commented

In particular, I'm guessing the generics in 0.2.10 translateFocus (guessing since the 0.2.10 source wasn't pushed, btw) look like

    @Override
    @Nonnull
    public IFocus<?> translateFocus(@Nonnull IFocus<T> focus, @Nonnull IIngredientHelper.IFocusFactory focusFactory) {
        return getIngredientHelper(((RecipeInfo<T, ?>)focus.getValue()).getResult())
            .translateFocus(focus, focusFactory);
    }

But the generics in that cast are wrong and removing them hints at the problem - focus needs to have its inner value translated when being passed to translateFocus as well. I am currently testing

    @Override
    @Nonnull
    public IFocus<?> translateFocus(@Nonnull IFocus<T> focus, @Nonnull IIngredientHelper.IFocusFactory focusFactory) {
        RecipeInfo<?, ?> r = focus.getValue();
        return getIngredientHelper(r.getResult())
            .translateFocus(focusFactory.createFocus(focus.getMode(), r.getResult()), focusFactory);
    }

(It doesn't crash the first few times I tried doing jei stuff, but neither did baseline 0.2.10)

commented

Yes, you're right, I forgot to deal with the real type, and the main reason why I didn't commit the code for 0.2.10 is that there was another feature that was going to be included, but I was busy with the jech development and forgot about it.

commented

I've included your code in 0.2.11 and it will be released on curseforge soon, thanks for your contribution.