Skip to content

IACustomIngredient

interface IACustomIngredient

Interface that modders can implement to create new recipe-matching behaviors beyond vanilla Ingredients, ported from Fabric's custom ingredient API to work cross-loader.

This is not directly implemented on vanilla Ingredients; use vanilla to convert a custom ingredient into one. On disk, a custom ingredient is encoded by its serializer, keyed by that serializer's registered identifier, plus whatever extra fields the serializer needs.

See also

Inheritors

Properties

matchingStacks

abstract val matchingStacks: MutableList<ItemStack>

The stacks that match this ingredient, for display purposes (e.g. in a recipe viewer).

Guidelines for good compatibility:

  • These stacks need not be exhaustive or perfectly accurate, except when requiresTesting is false, in which case they must correspond exactly to every accepted item.

  • At least one stack must be returned, or the ingredient is considered empty.

  • Try to include at least one stack per accepted item, so inspecting mods can enumerate what the ingredient might accept.

No caching is required here; the ingredient itself already caches this.

requiresTesting

abstract val requiresTesting: Boolean

Whether test must always be called to know if a stack matches, as opposed to relying on matchingStacks alone. false when this ingredient ignores extra stack data (like components/NBT) and matching is fully determined by item type.

serializer

The serializer for this ingredient. Must have been registered via IACustomIngredientSerializer.register.

vanilla

@get:



ApiStatus.NonExtendable



open val vanilla: Ingredient

Converts this custom ingredient into a vanilla Ingredient behaving the same way.

Functions

test

abstract fun test(stack: ItemStack): Boolean

Checks whether stack matches this ingredient. Must not modify stack.