Ingredients and Visibility [Minecraft 1.21 and 1.21.1] - mezz/JustEnoughItems GitHub Wiki
[!NOTE] Version note: This page covers ingredient visibility, extra ingredients, subtypes, aliases, and descriptions for Minecraft 1.21 and 1.21.1.
Other ingredient pages:
- Minecraft 1.21.11, 26.1.2, and 26.2: Ingredients and Visibility, Custom Ingredient Types, Search and Info Pages
- Minecraft 1.16.5, 1.18.2, 1.19.2, and 1.20.1: Adding/Hiding Items, Item Subtypes
- Minecraft 1.12.2: Adding Items, Hiding Ingredients, Item Subtypes, Non-Item Ingredients
Ingredients and Visibility
JEI's built-in item ingredient type is VanillaTypes.ITEM_STACK. Platform fluid ingredient types are NeoForgeTypes.FLUID_STACK on NeoForge, ForgeTypes.FLUID_STACK on Forge, and FabricTypes.FLUID_STACK on Fabric.
Adding Extra Ingredients
JEI discovers normal item stacks and fluids from the game, but some variants may not be discovered automatically. Use registerExtraIngredients to add extra ingredients to an existing type.
@Override
public void registerExtraIngredients(IExtraIngredientRegistration registration) {
registration.addExtraItemStacks(List.of(
ModItems.FILLED_BACKPACK.asItem().getDefaultInstance()
));
}
Use this for item stacks that are not in the creative menu, or for extra fluid stacks that differ from the default registry-derived fluids.
Custom Ingredient Types
Use registerIngredients only when your mod needs a new ingredient type, not just more item stacks or fluids.
@Override
public void registerIngredients(IModIngredientRegistration registration) {
registration.register(
MyIngredientTypes.SPELL,
getAllSpells(),
new SpellIngredientHelper(),
new SpellIngredientRenderer(),
SpellIngredient.CODEC
);
}
Custom ingredient types need an IIngredientType, a complete ingredient list, an IIngredientHelper, an IIngredientRenderer, and a codec for saving ingredients.
Runtime Additions and Hiding
Use IIngredientManager when ingredients are created or removed while the game is running, or when a server defines what should be visible.
IIngredientManager ingredientManager = jeiRuntime.getIngredientManager();
ingredientManager.addIngredientsAtRuntime(VanillaTypes.ITEM_STACK, stacksToAdd);
ingredientManager.removeIngredientsAtRuntime(VanillaTypes.ITEM_STACK, stacksToHide);
Do not use IEditModeConfig for normal mod-driven hiding. IEditModeConfig is for player-controlled edit-mode config screens.
Use IIngredientVisibility from IJeiHelpers.getIngredientVisibility() when you need to check whether an ingredient is currently visible in JEI, or listen for visibility changes.
Item and Fluid Subtypes
If two stacks of the same item should count as different ingredients, register subtype handling in registerItemSubtypes.
@Override
public void registerItemSubtypes(ISubtypeRegistration registration) {
registration.registerSubtypeInterpreter(ModItems.BACKPACK.asItem(), (stack, context) ->
stack.get(ModDataComponents.BACKPACK_COLOR)
);
}
Use registerFluidSubtypes for fluid subtype data.
Search Aliases
Use registerIngredientAliases to add words that help players find ingredients.
@Override
public void registerIngredientAliases(IIngredientAliasRegistration registration) {
registration.addAlias(
VanillaTypes.ITEM_STACK,
ModItems.ALLOY_DUST.asItem().getDefaultInstance(),
"blend"
);
registration.addAliases(
VanillaTypes.ITEM_STACK,
ModItems.WRENCH.asItem().getDefaultInstance(),
List.of("spanner", "tool")
);
}
Aliases may be literal search terms or translation keys. JEI skips this registration if the player disables search aliases in JEI's config.
For platform fluids or custom ingredient types, use the typed overloads with the ingredient type and ingredient instance.
Item Descriptions
Use registerRecipes to add JEI information pages for ingredients.
@Override
public void registerRecipes(IRecipeRegistration registration) {
registration.addIngredientInfo(
ModBlocks.CRUSHER,
Component.translatable("jei.examplemod.info.crusher")
);
}
Use addItemStackInfo for item stacks, or addIngredientInfo(ingredient, ingredientType, description) for fluids and custom ingredient types.