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>(Registry<T> registry) extends Record implements ICustomHolderSet<T>

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

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

    • registry

      private final Registry<T> registry
      The field for the registry record component.
  • Constructor Details

    • AnyHolderSet

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

    • codec

      public static <T> com.mojang.serialization.Codec<? 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 ForgeRegistries.HOLDER_SET_TYPES.
      Specified by:
      type in interface ICustomHolderSet<T>
      Returns:
      HolderSetType registered to 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>
    • isValidInRegistry

      public boolean isValidInRegistry(Registry<T> registry)
      Specified by:
      isValidInRegistry 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.
    • registry

      public Registry<T> registry()
      Returns the value of the registry record component.
      Returns:
      the value of the registry record component