Match custom ingredients
Implement Hooks::ingredient_test(context, event) to check a concrete stack's components for your custom ingredient kind. Calling Ingredient::test(host, stack) reaches this hook after any nonempty load-time candidate list accepts the stack's item.
From Sunrise's modding bookead8a1e
Set event.accept to false to reject the stack. It starts as true.
Callback contract
contextis the loop context of the side performing the match. The hook itself takes noHost.- The event supplies the ingredient kind, its retained NBT compound and the stack being matched.
- The callback can run many times during crafting. Give the same answer for the same stack and ingredient.
- An item absent from a nonempty load-time list fails without this callback. An empty custom list still invokes the predicate: manual crafting can match an accepted stack, although recipe-book placement, property sets and stonecutter selection are unavailable.
A client without this mod predicts vanilla here; the server corrects it.
Read event.data as an API Compound with typed Tag variants (Int, Long, List, Compound, and others). The loader converts recipe metadata once using vanilla JsonOps-to-NbtOps rules; matching does not reconvert it. Numeric JSON arrays remain lists. Nested null values refuse the ingredient and fail the recipe during loading.
Edit this page on GitHub · Spotted something wrong? Open an issue or ask on Discord.



