Interface ICustomIngredient
- All Known Implementing Classes:
BlockTagIngredient
,CompoundIngredient
,DataComponentIngredient
,DifferenceIngredient
,IntersectionIngredient
,TestEnabledIngredient
public interface ICustomIngredient
Interface that modders can implement to create new behaviors for
Ingredient
s.
This is not directly implemented on vanilla Ingredient
s, 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 TypeMethodDescriptiongetItems()
Returns the list of stacks that this ingredient accepts.getType()
Returns the type of this ingredient.boolean
isSimple()
Returns whether this ingredient always requires direct stack testing.boolean
Checks if a stack matches this ingredient.default Ingredient
Returns a newIngredient
behaving 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:
true
if the stack matches this ingredient,false
otherwise
-
getItems
Returns the list of stacks that this ingredient accepts.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 are simple,
for which it is important that the returned stacks correspond exactly to all the accepted
Item
s. - At least one stack must be returned for the ingredient not to be considered accidentally 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.
- Returns:
- the list of stacks that this ingredient accepts
-
isSimple
boolean isSimple()Returns whether this ingredient always requires direct stack testing.- Returns:
true
if this ingredient ignores NBT data when matching stacks,false
otherwise- 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
-
toVanilla
Returns a newIngredient
behaving as defined by this custom ingredient.- Returns:
- a new
Ingredient
behaving as defined by this custom ingredient
-