Record Class CompoundIngredient
java.lang.Object
java.lang.Record
net.neoforged.neoforge.common.crafting.CompoundIngredient
- All Implemented Interfaces:
ICustomIngredient
public record CompoundIngredient(List<Ingredient> children)
extends Record
implements ICustomIngredient
Ingredient that matches if any of the child ingredients match
-
Field Summary
Modifier and TypeFieldDescriptionprivate final List
<Ingredient> The field for thechildren
record component.static final com.mojang.serialization.MapCodec
<CompoundIngredient> -
Constructor Summary
ConstructorDescriptionCompoundIngredient
(List<Ingredient> children) Creates an instance of aCompoundIngredient
record class. -
Method Summary
Modifier and TypeMethodDescriptionchildren()
Returns the value of thechildren
record component.final boolean
Indicates whether some other object is "equal to" this one.getItems()
Returns the list of stacks that this ingredient accepts.getType()
Returns the type of this ingredient.final int
hashCode()
Returns a hash code value for this object.boolean
isSimple()
Returns whether this ingredient always requires direct stack testing.static Ingredient
of
(Ingredient... children) Creates a compound ingredient from the given list of ingredientsboolean
Checks if a stack matches this ingredient.final String
toString()
Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.neoforged.neoforge.common.crafting.ICustomIngredient
toVanilla
-
Field Details
-
children
The field for thechildren
record component. -
CODEC
-
-
Constructor Details
-
CompoundIngredient
Creates an instance of aCompoundIngredient
record class.- Parameters:
children
- the value for thechildren
record component
-
-
Method Details
-
of
Creates a compound ingredient from the given list of ingredients -
getItems
Description copied from interface:ICustomIngredient
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.
- Specified by:
getItems
in interfaceICustomIngredient
- Returns:
- the list of stacks that this ingredient accepts
-
test
Description copied from interface:ICustomIngredient
Checks if a stack matches this ingredient. The stack must not be modified in any way.- Specified by:
test
in interfaceICustomIngredient
- Parameters:
stack
- the stack to test- Returns:
true
if the stack matches this ingredient,false
otherwise
-
isSimple
public boolean isSimple()Description copied from interface:ICustomIngredient
Returns whether this ingredient always requires direct stack testing.- Specified by:
isSimple
in interfaceICustomIngredient
- Returns:
true
if this ingredient ignores NBT data when matching stacks,false
otherwise- See Also:
-
getType
Description copied from interface:ICustomIngredient
Returns the type of this ingredient.The type must be registered to
NeoForgeRegistries.INGREDIENT_TYPES
.- Specified by:
getType
in interfaceICustomIngredient
- Returns:
- the type of this ingredient
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
children
Returns the value of thechildren
record component.- Returns:
- the value of the
children
record component
-