Skip to content

AComponentsIngredient

Custom ingredient that matches stacks accepted by base and additionally requires their data components to match components (present components must equal the patch's value; absent components must stay absent). Build via of.

Types

Companion

object Companion

Serializer

Properties

base

val base: Ingredient

components

val components: DataComponentPatch

Non-empty patch of component values a matching stack must satisfy.

matchingStacks

open override 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

open override val requiresTesting: Boolean = true

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

open override fun test(stack: ItemStack): Boolean

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