Record Class AnyHolderSet<T>

java.lang.Object
java.lang.Record
net.neoforged.neoforge.registries.holdersets.AnyHolderSet<T>
All Implemented Interfaces:
Iterable<net.minecraft.core.Holder<T>>, net.minecraft.core.HolderSet<T>, IHolderSetExtension<T>, ICustomHolderSet<T>

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

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

 {
   "type": "neoforge:any"
 }
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     

    Nested classes/interfaces inherited from interface net.minecraft.core.HolderSet

    net.minecraft.core.HolderSet.Direct<T>, net.minecraft.core.HolderSet.ListBacked<T>, net.minecraft.core.HolderSet.Named<T>

    Nested classes/interfaces inherited from interface net.neoforged.neoforge.common.extensions.IHolderSetExtension

    IHolderSetExtension.SerializationType
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final net.minecraft.core.HolderLookup.RegistryLookup<T>
    The field for the registryLookup record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AnyHolderSet(net.minecraft.core.HolderLookup.RegistryLookup<T> registryLookup)
    Creates an instance of a AnyHolderSet record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canSerializeIn(net.minecraft.core.HolderOwner<T> holderOwner)
     
    boolean
    contains(net.minecraft.core.Holder<T> holder)
     
    final boolean
    Indicates whether some other object is "equal to" this one.
    net.minecraft.core.Holder<T>
    get(int i)
     
    Optional<net.minecraft.core.Holder<T>>
    getRandomElement(net.minecraft.util.RandomSource random)
     
    final int
    Returns a hash code value for this object.
    boolean
     
    Iterator<net.minecraft.core.Holder<T>>
     
    net.minecraft.core.HolderLookup.RegistryLookup<T>
    Returns the value of the registryLookup record component.
    int
     
    Stream<net.minecraft.core.Holder<T>>
     
    Returns a string representation of this record class.
    Returns HolderSetType registered to
    invalid reference
    ForgeRegistries.HOLDER_SET_TYPES
    .
    com.mojang.datafixers.util.Either<net.minecraft.tags.TagKey<T>,List<net.minecraft.core.Holder<T>>>
     
    Optional<net.minecraft.tags.TagKey<T>>
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface net.neoforged.neoforge.registries.holdersets.ICustomHolderSet

    serializationType

    Methods inherited from interface net.neoforged.neoforge.common.extensions.IHolderSetExtension

    addInvalidationListener

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

    • registryLookup

      private final net.minecraft.core.HolderLookup.RegistryLookup<T> registryLookup
      The field for the registryLookup record component.
  • Constructor Details

    • AnyHolderSet

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

    • 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<net.minecraft.core.Holder<T>> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • stream

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

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

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

      public Optional<net.minecraft.core.Holder<T>> getRandomElement(net.minecraft.util.RandomSource random)
      Specified by:
      getRandomElement in interface net.minecraft.core.HolderSet<T>
    • get

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

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

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

      public Optional<net.minecraft.tags.TagKey<T>> unwrapKey()
      Specified by:
      unwrapKey in interface net.minecraft.core.HolderSet<T>
    • isBound

      public boolean isBound()
      Specified by:
      isBound in interface net.minecraft.core.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 net.minecraft.core.HolderLookup.RegistryLookup<T> registryLookup()
      Returns the value of the registryLookup record component.
      Returns:
      the value of the registryLookup record component