Skip to content

IACustomIngredient

interface IACustomIngredient

Interface that modders can implement to create new behaviors for Ingredients.

This is not directly implemented on vanilla Ingredients, but conversions are possible:

  • .toVanilla converts a custom ingredient to a vanilla Ingredient.

  • FabricIngredient can be used to check if a vanilla Ingredient is custom, and retrieve the custom ingredient in that case.

The format for custom ingredients is as follows:

`{
"fabric:type": "",
// extra ingredient data, dependent on the serializer
}
`

*#### See also

Inheritors

Properties

matchingStacks

abstract val matchingStacks: MutableList<ItemStack>

Return

the list of stacks that match this ingredient.

The following guidelines should be followed for good compatibility:

  • These stacks are generally used for display purposes, and need not be exhaustive or perfectly accurate.

  • An exception is ingredients that .requiresTesting, for which it is important that the returned stacks correspond exactly to all the accepted Items.

  • At least one stack must be returned for the ingredient not to be considered empty.

  • The ingredient should try to return at least one stack with each accepted Item. This allows mods that inspect the ingredient to figure out which stacks it might accept.

Note: no caching needs to be done by the implementation, this is already handled by the ingredient itself.

requiresTesting

abstract val requiresTesting: Boolean

Returns whether this ingredient always requires .test.

Return

false if this ingredient ignores NBT data when matching stacks, true otherwise

See also

  • FabricIngredient.requiresTesting

serializer

Return

The serializer for this ingredient

The serializer must have been registered using IACustomIngredientSerializer.register.

vanilla

@get:



ApiStatus.NonExtendable



open val vanilla: Ingredient

Return

a new Ingredient behaving as defined by this custom ingredient.

Functions

test

abstract fun test(stack: ItemStack): Boolean

Checks if a stack matches this ingredient. The stack must not be modified in any way.

Return

true if the stack matches this ingredient, false otherwise

Parameters

  • stack: the stack to test