Recipe Categories [Minecraft 1.21 and 1.21.1] - mezz/JustEnoughItems GitHub Wiki
[!NOTE] Version note: This page covers recipe categories for Minecraft 1.21 and 1.21.1.
Other recipe category pages:
- Minecraft 1.21.11, 26.1.2, and 26.2: Recipe Categories
- Minecraft 1.16.5, 1.18.2, 1.19.2, and 1.20.1: Recipe Categories
- Minecraft 1.12.2: Recipe Categories
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()
.addIngredients(recipe.getInput());
builder.addOutputSlot(95, 19)
.setOutputSlotBackground()
.addItemStack(recipe.getResult());
}
@Override
public void createRecipeExtras(IRecipeExtrasBuilder builder, CrusherRecipe recipe, IFocusGroup focuses) {
builder.addAnimatedRecipeArrow(200)
.setPosition(45, 19);
}
}
Required Category Data
getRecipeType
Returns the RecipeType<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. If you extend AbstractRecipeCategory, these are provided by the constructor.
getIcon
Returns the category tab icon. Use IGuiHelper.createDrawableIngredient for ingredient icons. Returning null lets JEI try to use the first recipe catalyst 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 catalyst 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()
.addIngredients(recipe.getIngredient());
builder.addOutputSlot(61, 1)
.setOutputSlotBackground()
.addItemStack(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, 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 getRegistryName 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.