Interface ICustomIngredient
- All Known Implementing Classes:
BlockTagIngredient,CompoundIngredient,CustomDisplayIngredient,DataComponentIngredient,DifferenceIngredient,IntersectionIngredient
public interface ICustomIngredient
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 vanillaIngredient.Ingredient.getCustomIngredient()retrieves the custom ingredient inside a vanillaIngredient.
Implementations of this interface must implement Object.equals(java.lang.Object) and Object.hashCode()
to ensure that the ingredient also supports them.
-
Method Summary
Modifier and TypeMethodDescriptiondefault SlotDisplaydisplay()Returns the display for this ingredient.getType()Returns the type of this ingredient.booleanisSimple()Returns whether this ingredient always requires direct stack testing.items()Returns the list of items that this ingredient accepts.booleanChecks if a stack matches this ingredient.default IngredientReturns a newIngredientbehaving as defined by this custom ingredient.
-
Method Details
-
test
Checks if a stack matches this ingredient. The stack must not be modified in any way.- Parameters:
stack- the stack to test- Returns:
trueif the stack matches this ingredient,falseotherwise
-
items
Returns the list of items that this ingredient accepts.The following guidelines should be followed for good compatibility:
- At least one item must be returned for the ingredient not to be considered empty. Empty ingredients invalidate the entire recipe.
- The ingredient should return all
Items it might possible accept. This allows mods that inspect the ingredient to figure out which stacks it might accept. - Returned items might not always be accepted by the ingredient, as an ingredient might still perform additional NBT-dependent tests.
- An exception is ingredients that are simple,
for which
testing a stackis equivalent to testing if the item is in the returned list.
Note: no caching needs to be done by the implementation, this is already handled by the ingredient itself.
- Returns:
- the list of items that this ingredient accepts
-
isSimple
boolean isSimple()Returns whether this ingredient always requires direct stack testing.- Returns:
trueif this ingredient ignores NBT data when matching stacks,falseotherwise- See Also:
-
getType
IngredientType<?> getType()Returns the type of this ingredient.The type must be registered to
NeoForgeRegistries.INGREDIENT_TYPES.- Returns:
- the type of this ingredient
-
display
Returns the display for this ingredient.The display is synced to the client, and is also used to retrieve the
ItemStacks that are shown to the client. -
toVanilla
Returns a newIngredientbehaving as defined by this custom ingredient.- Returns:
- a new
Ingredientbehaving as defined by this custom ingredient
-