Just Enough Items (JEI)

Just Enough Items (JEI)

392M Downloads

[1.16.5] boolean isHandled appears to not work as documented from IRecipeCategory

Lothrazar opened this issue · 5 comments

commented

VERSION jei-1.16.5:7.7.1.121
Minecraft 1.16.5
Forge 36.2.2

Note: Maybe i am using isHandled wrong. My goal is to have only a custom subset of crafting recipes handled and showing up in the "recipe list" . For example, if i wanted every recipe where at least one ingredient is a stick or something. Custom logic to filter. isHandled is the closest i could find

This method in the interface says

	 * @return true if the given recipe can be handled by this category.
	 * @since JEI 7.2.0
	 */
	default boolean isHandled(T recipe) {

Im working on a machine that only works on a subset of vanilla recipes (kind of like anything shapeless where all ingredients match each other)

However, in my category when i code it like this

  @Override
  public boolean isHandled(ICraftingRecipe recipe) {
    System.out.println(recipe.getId() + " ISHANDLED!!");
    return false;
}

The println is never seen in the log, breakpoints are not hit. and every crafting recipe still comes up as 'handled' and is linked to the block

Source : https://github.com/Lothrazar/Cyclic/blob/465bfe8dd85df750782bdf21305478d03b09e0b8/src/main/java/com/lothrazar/cyclic/compat/jei/PackagerRecipeCategory.java#L61

My expected result is that, since i returned false, this list is empty and not 1400 long

every rec

commented

Nevermind, this was my fault . i had everything registered but i had to use catalyst with my own custom id, not the Vanila Recipe id . works fine

commented

This code should break everything. but it does nothing. function is never called as far as i can tell, as this exception is not in latest .log or default.log


  @Override
  public boolean isHandled(ICraftingRecipe recipe) {
    boolean testingBreakpoints = false;
    testingBreakpoints = true;
    if (testingBreakpoints) {
      throw new IllegalArgumentException("returning false does not work is really bad what is happening");
    }
    System.out.println(recipe.getId() + " ISHANDLED!!");
    return false;
  }
commented

Nevermind i was wrong again. This is a bug.

As you can see in my sample code, i literally hard coded it Throw an exception from isHandled.
Exception is never thrown.

isHandled is never called, system.outs dont show in log. Breakpoints in isHandled are never hit

My entire category
https://github.com/Lothrazar/Cyclic/blob/a55d1f134055eb0b10e7573aeb73d0627d5dfd0e/src/main/java/com/lothrazar/cyclic/compat/jei/PackagerRecipeCategory.java

Entire plugin
https://github.com/Lothrazar/Cyclic/blob/a55d1f134055eb0b10e7573aeb73d0627d5dfd0e/src/main/java/com/lothrazar/cyclic/compat/jei/CyclicPluginJEI.java

As a last resort,
I tested it also by checking if the recipe is valid on setRecipe and setIngredients.

My expected result is that, due to isHandled, these empty recipes not show up. but they do show up.

Returning true or false or throwing an exception from isHandled does the exact same thing which is nothing
reopen the issue

commented

This should be fixed in the latest versions on 1.16 and 1.17, please let me know if you run into any more issues!

commented

Thanks for the report!
I can confirm that this is only called on recipes handled by the vanilla plugin.
Generally mods don't add recipes to JEI that they can't handle, so I guess nobody ran into this issue.
I'll look into a fix.