Record Class IngredientComponent

java.lang.Object
java.lang.Record
dev.latvian.mods.kubejs.recipe.component.IngredientComponent
All Implemented Interfaces:
RecipeComponent<net.minecraft.world.item.crafting.Ingredient>

public record IngredientComponent(RecipeComponentType<?> type, com.mojang.serialization.Codec<net.minecraft.world.item.crafting.Ingredient> codec, boolean allowEmpty) extends Record implements RecipeComponent<net.minecraft.world.item.crafting.Ingredient>
  • Field Details

    • INGREDIENT

      public static final RecipeComponentType<net.minecraft.world.item.crafting.Ingredient> INGREDIENT
    • OPTIONAL_INGREDIENT

      public static final RecipeComponentType<net.minecraft.world.item.crafting.Ingredient> OPTIONAL_INGREDIENT
  • Constructor Details

    • IngredientComponent

      public IngredientComponent(RecipeComponentType<?> type, com.mojang.serialization.Codec<net.minecraft.world.item.crafting.Ingredient> codec, boolean allowEmpty)
      Creates an instance of a IngredientComponent record class.
      Parameters:
      type - the value for the type record component
      codec - the value for the codec record component
      allowEmpty - the value for the allowEmpty record component
  • Method Details

    • typeInfo

      public dev.latvian.mods.rhino.type.TypeInfo typeInfo()
      Description copied from interface: RecipeComponent
      Defines a description for how this component may be constructed. Type descriptions may be comprised of a primitive type such as a string, number or Java class (which may be useful if that that class has an appropriate type wrapper for it already), an array of fixed or dynamic length, a map / object, or a union of multiple types.

      Type descriptions are used by addons like ProbeJS to provide typing hints.

      Specified by:
      typeInfo in interface RecipeComponent<net.minecraft.world.item.crafting.Ingredient>
      Returns:
      A description of how this component may be constructed
    • hasPriority

      public boolean hasPriority(RecipeMatchContext cx, Object from)
      Description copied from interface: RecipeComponent
      Declares whether this component should take priority when being considered by e.g. an EitherRecipeComponent during deserialization.
      Specified by:
      hasPriority in interface RecipeComponent<net.minecraft.world.item.crafting.Ingredient>
      Parameters:
      cx - Script context
      from - The object to be deserialized from
      Returns:
      Whether this component should take priority
    • matches

      public boolean matches(RecipeMatchContext cx, net.minecraft.world.item.crafting.Ingredient value, ReplacementMatchInfo match)
      Specified by:
      matches in interface RecipeComponent<net.minecraft.world.item.crafting.Ingredient>
      Parameters:
      cx - Script context
      value - The value to check
      match - The replacement match to check against
      Returns:
      true if the given value matches the given replacement match.
    • isEmpty

      public boolean isEmpty(net.minecraft.world.item.crafting.Ingredient value)
      Description copied from interface: RecipeComponent
      Shallow empty check function
      Specified by:
      isEmpty in interface RecipeComponent<net.minecraft.world.item.crafting.Ingredient>
    • buildUniqueId

      public void buildUniqueId(UniqueIdBuilder builder, net.minecraft.world.item.crafting.Ingredient value)
      Specified by:
      buildUniqueId in interface RecipeComponent<net.minecraft.world.item.crafting.Ingredient>
    • toString

      public 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
    • toString

      public String toString(OpsContainer ops, net.minecraft.world.item.crafting.Ingredient value)
      Specified by:
      toString in interface RecipeComponent<net.minecraft.world.item.crafting.Ingredient>
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • type

      public RecipeComponentType<?> type()
      Returns the value of the type record component.
      Specified by:
      type in interface RecipeComponent<net.minecraft.world.item.crafting.Ingredient>
      Returns:
      the value of the type record component
    • codec

      public com.mojang.serialization.Codec<net.minecraft.world.item.crafting.Ingredient> codec()
      Returns the value of the codec record component.
      Specified by:
      codec in interface RecipeComponent<net.minecraft.world.item.crafting.Ingredient>
      Returns:
      the value of the codec record component
    • allowEmpty

      public boolean allowEmpty()
      Returns the value of the allowEmpty record component.
      Specified by:
      allowEmpty in interface RecipeComponent<net.minecraft.world.item.crafting.Ingredient>
      Returns:
      the value of the allowEmpty record component