Recipe Categories [Minecraft 1.21.11 to 26.2] - mezz/JustEnoughItems GitHub Wiki

[!NOTE] Version note: This page covers recipe categories for Minecraft 1.21.11, 26.1.2, and 26.2.

Other recipe category pages:

Recipe Categories

A recipe category defines how a recipe type is displayed in JEI. It provides the title, tab icon, layout size, ingredient slots, and any extra widgets or drawing.

Creating a Category

Implement IRecipeCategory<T> directly, or extend AbstractRecipeCategory<T> if the title, icon, width, and height are fixed.

public class CrusherRecipeCategory extends AbstractRecipeCategory<CrusherRecipe> {
  public CrusherRecipeCategory(IGuiHelper guiHelper) {
    super(
      ExampleJeiPlugin.CRUSHING,
      Component.translatable("jei.examplemod.crushing"),
      guiHelper.createDrawableIngredient(
        VanillaTypes.ITEM_STACK,
        ModBlocks.CRUSHER.asItem().getDefaultInstance()
      ),
      116,
      54
    );
  }

  @Override
  public void setRecipe(IRecipeLayoutBuilder builder, CrusherRecipe recipe, IFocusGroup focuses) {
    builder.addInputSlot(1, 19)
      .setStandardSlotBackground()
      .add(recipe.getInput());

    builder.addOutputSlot(95, 19)
      .setOutputSlotBackground()
      .add(recipe.getResult());
  }

  @Override
  public void createRecipeExtras(IRecipeExtrasBuilder builder, CrusherRecipe recipe, IFocusGroup focuses) {
    builder.addAnimatedRecipeArrow(200)
      .setPosition(45, 19);
  }
}

Required Category Data

getRecipeType

Returns the IRecipeType<T> handled by this category.

getTitle

Returns the title drawn at the top of the recipe page.

getWidth and getHeight

Return the size of recipe layouts in this category. In these Minecraft versions, categories do not use the old getBackground method.

getIcon

Returns the category tab icon. Use IGuiHelper.createDrawableIngredient for ingredient icons. Returning null lets JEI try to use the first crafting station as the icon.

setRecipe

Adds slots and ingredients to the IRecipeLayoutBuilder. JEI uses these slots for display and for recipe lookup.

Building Recipe Layouts

Use IRecipeLayoutBuilder to add slots:

  • addInputSlot(x, y) for visible inputs.
  • addOutputSlot(x, y) for visible outputs.
  • addSlot(role, x, y) for crafting station or render-only roles.
  • addInvisibleIngredients(role) for lookup ingredients that should not be drawn.

Each slot returns an IRecipeSlotBuilder. Use it to add ingredients and configure rendering:

builder.addInputSlot(1, 1)
  .setStandardSlotBackground()
  .add(recipe.getIngredient());

builder.addOutputSlot(61, 1)
  .setOutputSlotBackground()
  .add(recipe.getOutput());

Slots can add item stacks, item-like objects, vanilla Ingredients, fluids, typed ingredients, or custom ingredient types. For fluid displays, use setFluidRenderer when the default 16x16 renderer is not right.

Extra Drawing and Widgets

Use createRecipeExtras for per-recipe UI such as arrows, flames, text, scroll boxes, scroll grids, custom widgets, and input handlers.

Use draw for simple custom drawing that does not need persistent per-recipe state.

Use getTooltip for tooltips outside ingredient slots. To add to ingredient slot tooltips, use IRecipeSlotBuilder.addRichTooltipCallback.

Use onDisplayedIngredientsUpdate only when displayed outputs depend on the currently displayed rotating inputs. These display overrides are visual only and are not searchable recipe lookup data.

Recipe Identity

Override getIdentifier if your recipe is not a RecipeHolder and has a stable id. JEI uses this id for advanced tooltips and recipe bookmarks.

Override getCodec when your recipe type needs efficient bookmark serialization or cannot be looked up reliably by id.