Record Class AnyHolderSet<T>

java.lang.Object
java.lang.Record
net.minecraftforge.registries.holdersets.AnyHolderSet<T>
All Implemented Interfaces:
Iterable<Holder<T>>, HolderSet<T>, IForgeHolderSet<T>, ICustomHolderSet<T>

public record AnyHolderSet<T>(HolderLookup.RegistryLookup<T> registryLookup) extends Record implements ICustomHolderSet<T>

Holderset that represents all elements of a registry. Json format:

 {
   "type": "forge:any"
 }
 
  • Field Details

  • Constructor Details

    • AnyHolderSet

      public AnyHolderSet(HolderLookup.RegistryLookup<T> registryLookup)
      Creates an instance of a AnyHolderSet record class.
      Parameters:
      registryLookup - the value for the registryLookup record component
  • Method Details

    • codec

      public static <T> com.mojang.serialization.MapCodec<? extends ICustomHolderSet<T>> codec(ResourceKey<? extends Registry<T>> registryKey, com.mojang.serialization.Codec<Holder<T>> holderCodec, boolean forceList)
    • type

      public HolderSetType type()
      Description copied from interface: ICustomHolderSet
      Returns HolderSetType registered to
      invalid reference
      ForgeRegistries.HOLDER_SET_TYPES
      .
      Specified by:
      type in interface ICustomHolderSet<T>
      Returns:
      HolderSetType registered to
      invalid reference
      ForgeRegistries.HOLDER_SET_TYPES
    • iterator

      public Iterator<Holder<T>> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • stream

      public Stream<Holder<T>> stream()
      Specified by:
      stream in interface HolderSet<T>
    • size

      public int size()
      Specified by:
      size in interface HolderSet<T>
    • unwrap

      public com.mojang.datafixers.util.Either<TagKey<T>,List<Holder<T>>> unwrap()
      Specified by:
      unwrap in interface HolderSet<T>
    • getRandomElement

      public Optional<Holder<T>> getRandomElement(RandomSource random)
      Specified by:
      getRandomElement in interface HolderSet<T>
    • get

      public Holder<T> get(int i)
      Specified by:
      get in interface HolderSet<T>
    • contains

      public boolean contains(Holder<T> holder)
      Specified by:
      contains in interface HolderSet<T>
    • canSerializeIn

      public boolean canSerializeIn(HolderOwner<T> holderOwner)
      Specified by:
      canSerializeIn in interface HolderSet<T>
    • unwrapKey

      public Optional<TagKey<T>> unwrapKey()
      Specified by:
      unwrapKey in interface HolderSet<T>
    • 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
    • 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.
    • registryLookup

      public HolderLookup.RegistryLookup<T> registryLookup()
      Returns the value of the registryLookup record component.
      Returns:
      the value of the registryLookup record component