Record Class TestEnabledIngredient

java.lang.Object
java.lang.Record
net.neoforged.testframework.condition.TestEnabledIngredient
All Implemented Interfaces:
ICustomIngredient

public record TestEnabledIngredient(net.minecraft.world.item.crafting.Ingredient base, TestFramework framework, String testId) extends Record implements ICustomIngredient
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final net.minecraft.world.item.crafting.Ingredient
    The field for the base record component.
    static final com.mojang.serialization.MapCodec<TestEnabledIngredient>
     
    private final TestFramework
    The field for the framework record component.
    private final String
    The field for the testId record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TestEnabledIngredient(net.minecraft.world.item.crafting.Ingredient base, TestFramework framework, String testId)
    Creates an instance of a TestEnabledIngredient record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.item.crafting.Ingredient
    Returns the value of the base record component.
    net.minecraft.world.item.crafting.display.SlotDisplay
    Returns the display for this ingredient.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the framework record component.
    Returns the type of this ingredient.
    final int
    Returns a hash code value for this object.
    boolean
    Returns whether this ingredient always requires direct stack testing.
    Stream<net.minecraft.core.Holder<net.minecraft.world.item.Item>>
    Returns the list of items that this ingredient accepts.
    boolean
    test(net.minecraft.world.item.ItemStack stack)
    Checks if a stack matches this ingredient.
    Returns the value of the testId record component.
    final String
    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

    • base

      private final net.minecraft.world.item.crafting.Ingredient base
      The field for the base record component.
    • framework

      private final TestFramework framework
      The field for the framework record component.
    • testId

      private final String testId
      The field for the testId record component.
    • CODEC

      public static final com.mojang.serialization.MapCodec<TestEnabledIngredient> CODEC
  • Constructor Details

    • TestEnabledIngredient

      public TestEnabledIngredient(net.minecraft.world.item.crafting.Ingredient base, TestFramework framework, String testId)
      Creates an instance of a TestEnabledIngredient record class.
      Parameters:
      base - the value for the base record component
      framework - the value for the framework record component
      testId - the value for the testId record component
  • Method Details

    • test

      public boolean test(net.minecraft.world.item.ItemStack stack)
      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 interface ICustomIngredient
      Parameters:
      stack - the stack to test
      Returns:
      true if the stack matches this ingredient, false otherwise
    • items

      public Stream<net.minecraft.core.Holder<net.minecraft.world.item.Item>> items()
      Description copied from interface: ICustomIngredient
      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 stack is 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:
      items in interface ICustomIngredient
      Returns:
      the list of items that this ingredient accepts
    • isSimple

      public boolean isSimple()
      Description copied from interface: ICustomIngredient
      Returns whether this ingredient always requires direct stack testing.
      Specified by:
      isSimple in interface ICustomIngredient
      Returns:
      true if this ingredient ignores NBT data when matching stacks, false otherwise
      See Also:
      • Ingredient.isSimple()
    • getType

      public IngredientType<?> 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 interface ICustomIngredient
      Returns:
      the type of this ingredient
    • display

      public net.minecraft.world.item.crafting.display.SlotDisplay display()
      Description copied from interface: ICustomIngredient
      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.

      Specified by:
      display in interface ICustomIngredient
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • base

      public net.minecraft.world.item.crafting.Ingredient base()
      Returns the value of the base record component.
      Returns:
      the value of the base record component
    • framework

      public TestFramework framework()
      Returns the value of the framework record component.
      Returns:
      the value of the framework record component
    • testId

      public String testId()
      Returns the value of the testId record component.
      Returns:
      the value of the testId record component