Record Class ItemPredicate

java.lang.Object
java.lang.Record
net.minecraft.advancements.critereon.ItemPredicate

public record ItemPredicate(Optional<TagKey<Item>> tag, Optional<HolderSet<Item>> items, MinMaxBounds.Ints count, MinMaxBounds.Ints durability, List<EnchantmentPredicate> enchantments, List<EnchantmentPredicate> storedEnchantments, Optional<Holder<Potion>> potion, Optional<NbtPredicate> nbt) extends Record
  • Field Details

    • tag

      private final Optional<TagKey<Item>> tag
      The field for the tag record component.
    • items

      private final Optional<HolderSet<Item>> items
      The field for the items record component.
    • count

      private final MinMaxBounds.Ints count
      The field for the count record component.
    • durability

      private final MinMaxBounds.Ints durability
      The field for the durability record component.
    • enchantments

      private final List<EnchantmentPredicate> enchantments
      The field for the enchantments record component.
    • storedEnchantments

      private final List<EnchantmentPredicate> storedEnchantments
      The field for the storedEnchantments record component.
    • potion

      private final Optional<Holder<Potion>> potion
      The field for the potion record component.
    • nbt

      private final Optional<NbtPredicate> nbt
      The field for the nbt record component.
    • ITEMS_CODEC

      private static final com.mojang.serialization.Codec<HolderSet<Item>> ITEMS_CODEC
    • CODEC

      public static final com.mojang.serialization.Codec<ItemPredicate> CODEC
  • Constructor Details

    • ItemPredicate

      public ItemPredicate(Optional<TagKey<Item>> tag, Optional<HolderSet<Item>> items, MinMaxBounds.Ints count, MinMaxBounds.Ints durability, List<EnchantmentPredicate> enchantments, List<EnchantmentPredicate> storedEnchantments, Optional<Holder<Potion>> potion, Optional<NbtPredicate> nbt)
      Creates an instance of a ItemPredicate record class.
      Parameters:
      tag - the value for the tag record component
      items - the value for the items record component
      count - the value for the count record component
      durability - the value for the durability record component
      enchantments - the value for the enchantments record component
      storedEnchantments - the value for the storedEnchantments record component
      potion - the value for the potion record component
      nbt - the value for the nbt record component
  • Method Details

    • matches

      public boolean matches(ItemStack p_45050_)
    • fromJson

      public static Optional<ItemPredicate> fromJson(@Nullable com.google.gson.JsonElement p_45052_)
    • serializeToJson

      public com.google.gson.JsonElement serializeToJson()
    • serializeToJsonArray

      public static com.google.gson.JsonElement serializeToJsonArray(List<ItemPredicate> p_298997_)
    • fromJsonArray

      public static List<ItemPredicate> fromJsonArray(@Nullable com.google.gson.JsonElement p_45056_)
    • 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.
    • tag

      public Optional<TagKey<Item>> tag()
      Returns the value of the tag record component.
      Returns:
      the value of the tag record component
    • items

      public Optional<HolderSet<Item>> items()
      Returns the value of the items record component.
      Returns:
      the value of the items record component
    • count

      public MinMaxBounds.Ints count()
      Returns the value of the count record component.
      Returns:
      the value of the count record component
    • durability

      public MinMaxBounds.Ints durability()
      Returns the value of the durability record component.
      Returns:
      the value of the durability record component
    • enchantments

      public List<EnchantmentPredicate> enchantments()
      Returns the value of the enchantments record component.
      Returns:
      the value of the enchantments record component
    • storedEnchantments

      public List<EnchantmentPredicate> storedEnchantments()
      Returns the value of the storedEnchantments record component.
      Returns:
      the value of the storedEnchantments record component
    • potion

      public Optional<Holder<Potion>> potion()
      Returns the value of the potion record component.
      Returns:
      the value of the potion record component
    • nbt

      public Optional<NbtPredicate> nbt()
      Returns the value of the nbt record component.
      Returns:
      the value of the nbt record component