Record Class RegistryEntry.Direct<T>

java.lang.Object
java.lang.Record
net.minecraft.registry.entry.RegistryEntry.Direct<T>
Record Components:
value -
All Implemented Interfaces:
RegistryEntry<T>
Enclosing interface:
RegistryEntry<T>

public static record RegistryEntry.Direct<T>(T value) extends Record implements RegistryEntry<T>
A direct registry entry holds the value directly. The value does not have to be registered in a registry. Therefore, they receive no ID or registry key, and they cannot be tagged.

This is most often used in data packs to inline one-time use values directly.

Mappings:
Namespace Name
named net/minecraft/registry/entry/RegistryEntry$Direct
intermediary net/minecraft/class_6880$class_6881
official jm$a
named value
intermediary comp_349
official a
  • Field Details

    • value

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

    • Direct

      public Direct(T t)
  • Method Details

    • hasKeyAndValue

      public boolean hasKeyAndValue()
      Specified by:
      hasKeyAndValue in interface RegistryEntry<T>
      Mappings:
      Namespace Name Mixin selector
      named hasKeyAndValue Lnet/minecraft/registry/entry/RegistryEntry;hasKeyAndValue()Z
      intermediary method_40227 Lnet/minecraft/class_6880;method_40227()Z
      official b Ljm;b()Z
    • matchesId

      public boolean matchesId(Identifier id)
      Returns whether the ID of this entry is id.

      This always returns false for direct entries.

      Specified by:
      matchesId in interface RegistryEntry<T>
      Returns:
      whether the ID of this entry is id
      Mappings:
      Namespace Name Mixin selector
      named matchesId Lnet/minecraft/registry/entry/RegistryEntry;matchesId(Lnet/minecraft/util/Identifier;)Z
      intermediary method_40226 Lnet/minecraft/class_6880;method_40226(Lnet/minecraft/class_2960;)Z
      official a Ljm;a(Lakr;)Z
    • matchesKey

      public boolean matchesKey(RegistryKey<T> key)
      Returns whether the registry key of this entry is key.

      This always returns false for direct entries.

      Specified by:
      matchesKey in interface RegistryEntry<T>
      Returns:
      whether the registry key of this entry is key
      Mappings:
      Namespace Name Mixin selector
      named matchesKey Lnet/minecraft/registry/entry/RegistryEntry;matchesKey(Lnet/minecraft/registry/RegistryKey;)Z
      intermediary method_40225 Lnet/minecraft/class_6880;method_40225(Lnet/minecraft/class_5321;)Z
      official a Ljm;a(Lakq;)Z
    • isIn

      public boolean isIn(TagKey<T> tag)
      Returns whether this entry is in tag.

      This always returns false for direct entries, since tags are managed by a registry.

      Specified by:
      isIn in interface RegistryEntry<T>
      Returns:
      whether this entry is in tag
      Mappings:
      Namespace Name Mixin selector
      named isIn Lnet/minecraft/registry/entry/RegistryEntry;isIn(Lnet/minecraft/registry/tag/TagKey;)Z
      intermediary method_40220 Lnet/minecraft/class_6880;method_40220(Lnet/minecraft/class_6862;)Z
      official a Ljm;a(Lawu;)Z
    • matches

      public boolean matches(RegistryEntry<T> entry)
      Specified by:
      matches in interface RegistryEntry<T>
      Mappings:
      Namespace Name Mixin selector
      named matches Lnet/minecraft/registry/entry/RegistryEntry;matches(Lnet/minecraft/registry/entry/RegistryEntry;)Z
      intermediary method_55838 Lnet/minecraft/class_6880;method_55838(Lnet/minecraft/class_6880;)Z
      official a Ljm;a(Ljm;)Z
    • matches

      public boolean matches(Predicate<RegistryKey<T>> predicate)
      Returns whether this entry's key matches predicate.

      This always returns false for direct entries.

      Specified by:
      matches in interface RegistryEntry<T>
      Returns:
      whether this entry's key matches predicate
      Mappings:
      Namespace Name Mixin selector
      named matches Lnet/minecraft/registry/entry/RegistryEntry;matches(Ljava/util/function/Predicate;)Z
      intermediary method_40224 Lnet/minecraft/class_6880;method_40224(Ljava/util/function/Predicate;)Z
      official a Ljm;a(Ljava/util/function/Predicate;)Z
    • getKeyOrValue

      public com.mojang.datafixers.util.Either<RegistryKey<T>,T> getKeyOrValue()
      Returns the object that identifies this registry key.

      For direct entries, this is the held value, and for reference entries, this is the key of the entry.

      Specified by:
      getKeyOrValue in interface RegistryEntry<T>
      Returns:
      the object that identifies this registry key
      Mappings:
      Namespace Name Mixin selector
      named getKeyOrValue Lnet/minecraft/registry/entry/RegistryEntry;getKeyOrValue()Lcom/mojang/datafixers/util/Either;
      intermediary method_40229 Lnet/minecraft/class_6880;method_40229()Lcom/mojang/datafixers/util/Either;
      official d Ljm;d()Lcom/mojang/datafixers/util/Either;
    • getKey

      public Optional<RegistryKey<T>> getKey()
      Returns the registry key of this entry, or an empty optional if this is a direct entry.
      Specified by:
      getKey in interface RegistryEntry<T>
      Returns:
      the registry key of this entry, or an empty optional if this is a direct entry
      Mappings:
      Namespace Name Mixin selector
      named getKey Lnet/minecraft/registry/entry/RegistryEntry;getKey()Ljava/util/Optional;
      intermediary method_40230 Lnet/minecraft/class_6880;method_40230()Ljava/util/Optional;
      official e Ljm;e()Ljava/util/Optional;
    • getType

      public RegistryEntry.Type getType()
      Returns the type (direct or reference) of this registry entry.

      This is different from the types of reference registry entries, i.e. stand-alone or intrusive.

      Specified by:
      getType in interface RegistryEntry<T>
      Returns:
      the type (direct or reference) of this registry entry
      Mappings:
      Namespace Name Mixin selector
      named getType Lnet/minecraft/registry/entry/RegistryEntry;getType()Lnet/minecraft/registry/entry/RegistryEntry$Type;
      intermediary method_40231 Lnet/minecraft/class_6880;method_40231()Lnet/minecraft/class_6880$class_6882;
      official f Ljm;f()Ljm$b;
    • 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
    • ownerEquals

      public boolean ownerEquals(RegistryEntryOwner<T> owner)
      Specified by:
      ownerEquals in interface RegistryEntry<T>
      Mappings:
      Namespace Name Mixin selector
      named ownerEquals Lnet/minecraft/registry/entry/RegistryEntry;ownerEquals(Lnet/minecraft/registry/entry/RegistryEntryOwner;)Z
      intermediary method_46745 Lnet/minecraft/class_6880;method_46745(Lnet/minecraft/class_7876;)Z
      official a Ljm;a(Ljp;)Z
    • streamTags

      public Stream<TagKey<T>> streamTags()
      Returns a stream of the tags of this entry, or an empty stream if this is a direct entry.
      Specified by:
      streamTags in interface RegistryEntry<T>
      Returns:
      a stream of the tags of this entry, or an empty stream if this is a direct entry
      Mappings:
      Namespace Name Mixin selector
      named streamTags Lnet/minecraft/registry/entry/RegistryEntry;streamTags()Ljava/util/stream/Stream;
      intermediary method_40228 Lnet/minecraft/class_6880;method_40228()Ljava/util/stream/Stream;
      official c Ljm;c()Ljava/util/stream/Stream;
    • 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 object)
      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:
      object - the object with which to compare
      Returns:
      true if this object is the same as the object argument; false otherwise.
    • value

      public T value()
      Returns the value of the value record component.
      Specified by:
      value in interface RegistryEntry<T>
      Returns:
      the value of the value record component