Ingredient
can be validated based on the three ways you can construct Ingredients
- single item
- item list
- item tag
Creation
ValidatedIngredients are constructed from one of three constructors based on the default type of ingredient
// A validated Ingredient for a single itempublic ValidatedIngredient validatedIngredientItem = new ValidatedIngredient(Identifier.of("oak_log"));// A validated ingredient accepting a set of itemspublic ValidatedIngredient validatedIngredientList = new ValidatedIngredient(Set.of(Identifier.of("oak_log"), Identifier.of("dark_oak_log")));// A validated ingredient utilizing a tagpublic ValidatedIngredient validatedIngredientTag = new ValidatedIngredient(ItemTags.LOGS_THAT_BURN);//get the ingredient from the holder for use in Materials etcpublic Ingredient validatedIngredientIngredient = validatedIngredientItem.toIngredient();
Usage
ValidatedIngredient
is not an ingredient itself, and does not hold ingredients. It lazily creates ingredients only when needed. This prevents an ingredient from being created before the source for the ingredient is ready (before a tag is populated, for example).
Call toIngredient()
to supply an ingredient.
Heads up!
See the documentation page here 🗗