Record Class Holder.Direct<T>

java.lang.Object
java.lang.Record
net.minecraft.core.Holder.Direct<T>
All Implemented Interfaces:
Holder<T>, IReverseTag<T>
Enclosing interface:
Holder<T>

public static record Holder.Direct<T>(T value) extends Record implements Holder<T>
  • Field Details

    • value

      private final T value
      The field for the value record component.
  • Constructor Details

    • Direct

      public Direct(T value)
      Creates an instance of a Direct record class.
      Parameters:
      value - the value for the value record component
  • Method Details

    • isBound

      public boolean isBound()
      Specified by:
      isBound in interface Holder<T>
    • is

      public boolean is(ResourceLocation p_205727_)
      Specified by:
      is in interface Holder<T>
    • is

      public boolean is(ResourceKey<T> p_205725_)
      Specified by:
      is in interface Holder<T>
    • is

      public boolean is(TagKey<T> p_205719_)
      Specified by:
      is in interface Holder<T>
    • is

      public boolean is(Predicate<ResourceKey<T>> p_205723_)
      Specified by:
      is in interface Holder<T>
    • unwrap

      public com.mojang.datafixers.util.Either<ResourceKey<T>,T> unwrap()
      Specified by:
      unwrap in interface Holder<T>
    • unwrapKey

      public Optional<ResourceKey<T>> unwrapKey()
      Specified by:
      unwrapKey in interface Holder<T>
    • kind

      public Holder.Kind kind()
      Specified by:
      kind in interface Holder<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
    • isValidInRegistry

      public boolean isValidInRegistry(Registry<T> p_205721_)
      Specified by:
      isValidInRegistry in interface Holder<T>
    • tags

      public Stream<TagKey<T>> tags()
      Specified by:
      tags in interface Holder<T>
    • value

      public T value()
      Returns the value of the value record component.
      Specified by:
      value in interface Holder<T>
      Returns:
      the value of the value record component
    • 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.