Record Class CustomDisplayIngredient
java.lang.Object
java.lang.Record
net.neoforged.neoforge.common.crafting.CustomDisplayIngredient
- All Implemented Interfaces:
ICustomIngredient
public record CustomDisplayIngredient(Ingredient base, SlotDisplay display)
extends Record
implements ICustomIngredient
Ingredient that wraps another ingredient to override its
SlotDisplay.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IngredientThe field for thebaserecord component.static final com.mojang.serialization.MapCodec<CustomDisplayIngredient> private final SlotDisplayThe field for thedisplayrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionCustomDisplayIngredient(Ingredient base, SlotDisplay display) Creates an instance of aCustomDisplayIngredientrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbase()Returns the value of thebaserecord component.display()Returns the value of thedisplayrecord component.final booleanIndicates whether some other object is "equal to" this one.getType()Returns the type of this ingredient.final inthashCode()Returns a hash code value for this object.booleanisSimple()Returns whether this ingredient always requires direct stack testing.items()Returns the list of items that this ingredient accepts.static Ingredientof(Ingredient base, SlotDisplay display) booleanChecks if a stack matches this ingredient.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.common.crafting.ICustomIngredient
toVanilla
-
Field Details
-
base
The field for thebaserecord component. -
display
The field for thedisplayrecord component. -
CODEC
-
-
Constructor Details
-
CustomDisplayIngredient
Creates an instance of aCustomDisplayIngredientrecord class.- Parameters:
base- the value for thebaserecord componentdisplay- the value for thedisplayrecord component
-
-
Method Details
-
of
-
test
Description copied from interface:ICustomIngredientChecks if a stack matches this ingredient. The stack must not be modified in any way.- Specified by:
testin interfaceICustomIngredient- Parameters:
stack- the stack to test- Returns:
trueif the stack matches this ingredient,falseotherwise
-
items
Description copied from interface:ICustomIngredientReturns 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.
- Specified by:
itemsin interfaceICustomIngredient- Returns:
- the list of items that this ingredient accepts
-
isSimple
public boolean isSimple()Description copied from interface:ICustomIngredientReturns whether this ingredient always requires direct stack testing.- Specified by:
isSimplein interfaceICustomIngredient- Returns:
trueif this ingredient ignores NBT data when matching stacks,falseotherwise- See Also:
-
getType
Description copied from interface:ICustomIngredientReturns the type of this ingredient.The type must be registered to
NeoForgeRegistries.INGREDIENT_TYPES.- Specified by:
getTypein 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). -
base
Returns the value of thebaserecord component.- Returns:
- the value of the
baserecord component
-
display
Returns the value of thedisplayrecord component.- Specified by:
displayin interfaceICustomIngredient- Returns:
- the value of the
displayrecord component
-