Class RegistryEntry.Reference<T>

java.lang.Object
net.minecraft.util.registry.RegistryEntry.Reference<T>
All Implemented Interfaces:
RegistryEntry<T>
Enclosing interface:
RegistryEntry<T>

public static class RegistryEntry.Reference<T> extends Object implements RegistryEntry<T>
A reference registry entry holds the value by reference. The value is previously registered in a registry, so they can be referred to by their registry keys. This object also holds the entry's tags.

There are two types of reference registry entries.

  • Stand-alone registry entries are first instantiated by its key, and the value is set when registering the value. This is used by most of the registries.
  • Intrusive registry entries are registry entries tied to a specific registerable object at instantiation time. When instantiating those, it promises that the object is later registered - which, if broken, will result in a crash. This is used for Registry.BLOCK, Registry.ITEM, Registry.FLUID, Registry.ENTITY_TYPE, and Registry.GAME_EVENT registries. This type exists for historical reasons and is deprecated.

Therefore, it is very important to construct any intrusive-entry type object and register at the same time. For example, a mod that conditionally registers an Item has to create an instance only if the condition is met. (See Registry for a code example.)

When a reference registry entry is first instantiated, it only has either the key or the value (depending on the type). They are later filled when registering the entry at

invalid @link
#setKeyAndValue
. Attempting to call methods before those fields are filled can cause a crash. Note that if you are just getting the entry from a registry, this should not be a problem.
See Also:
Mappings:
Namespace Name
official gx$c
intermediary net/minecraft/class_6880$class_6883
named net/minecraft/util/registry/RegistryEntry$Reference
  • Field Details

    • field_40930

      private final class_7876<T> field_40930
      Mappings:
      Namespace Name Mixin selector
      official a Lgx$c;a:Lha;
      intermediary field_40930 Lnet/minecraft/class_6880$class_6883;field_40930:Lnet/minecraft/class_7876;
      named field_40930 Lnet/minecraft/util/registry/RegistryEntry$Reference;field_40930:Lnet/minecraft/class_7876;
    • tags

      private Set<TagKey<T>> tags
      Mappings:
      Namespace Name Mixin selector
      official b Lgx$c;b:Ljava/util/Set;
      intermediary field_36450 Lnet/minecraft/class_6880$class_6883;field_36450:Ljava/util/Set;
      named tags Lnet/minecraft/util/registry/RegistryEntry$Reference;tags:Ljava/util/Set;
    • referenceType

      private final RegistryEntry.Reference.Type referenceType
      Mappings:
      Namespace Name Mixin selector
      official c Lgx$c;c:Lgx$c$a;
      intermediary field_36451 Lnet/minecraft/class_6880$class_6883;field_36451:Lnet/minecraft/class_6880$class_6883$class_6884;
      named referenceType Lnet/minecraft/util/registry/RegistryEntry$Reference;referenceType:Lnet/minecraft/util/registry/RegistryEntry$Reference$Type;
    • registryKey

      @Nullable private @Nullable RegistryKey<T> registryKey
      Mappings:
      Namespace Name Mixin selector
      official d Lgx$c;d:Laby;
      intermediary field_36452 Lnet/minecraft/class_6880$class_6883;field_36452:Lnet/minecraft/class_5321;
      named registryKey Lnet/minecraft/util/registry/RegistryEntry$Reference;registryKey:Lnet/minecraft/util/registry/RegistryKey;
    • value

      @Nullable private T value
      Mappings:
      Namespace Name Mixin selector
      official e Lgx$c;e:Ljava/lang/Object;
      intermediary field_36453 Lnet/minecraft/class_6880$class_6883;field_36453:Ljava/lang/Object;
      named value Lnet/minecraft/util/registry/RegistryEntry$Reference;value:Ljava/lang/Object;
  • Constructor Details

    • Reference

      private Reference(RegistryEntry.Reference.Type referenceType, class_7876<T> class_7876, @Nullable @Nullable RegistryKey<T> registryKey, @Nullable T value)
      Mappings:
      Namespace Name Mixin selector
      official <init> Lgx$c;<init>(Lgx$c$a;Lha;Laby;Ljava/lang/Object;)V
      intermediary <init> Lnet/minecraft/class_6880$class_6883;<init>(Lnet/minecraft/class_6880$class_6883$class_6884;Lnet/minecraft/class_7876;Lnet/minecraft/class_5321;Ljava/lang/Object;)V
      named <init> Lnet/minecraft/util/registry/RegistryEntry$Reference;<init>(Lnet/minecraft/util/registry/RegistryEntry$Reference$Type;Lnet/minecraft/class_7876;Lnet/minecraft/util/registry/RegistryKey;Ljava/lang/Object;)V
  • Method Details

    • standAlone

      public static <T> RegistryEntry.Reference<T> standAlone(class_7876<T> class_7876, RegistryKey<T> registryKey)
      Returns a new stand-alone registry entry.

      This should not be called manually. Call Registry.entryOf(net.minecraft.util.registry.RegistryKey<T>) or Registry.getEntry(int) instead.

      Callers are responsible for filling the value later by calling

      invalid @link
      #setKeyAndValue
      .
      Returns:
      a new stand-alone registry entry
      Mappings:
      Namespace Name Mixin selector
      official a Lgx$c;a(Lha;Laby;)Lgx$c;
      intermediary method_40234 Lnet/minecraft/class_6880$class_6883;method_40234(Lnet/minecraft/class_7876;Lnet/minecraft/class_5321;)Lnet/minecraft/class_6880$class_6883;
      named standAlone Lnet/minecraft/util/registry/RegistryEntry$Reference;standAlone(Lnet/minecraft/class_7876;Lnet/minecraft/util/registry/RegistryKey;)Lnet/minecraft/util/registry/RegistryEntry$Reference;
    • intrusive

      @Deprecated public static <T> RegistryEntry.Reference<T> intrusive(class_7876<T> class_7876, @Nullable T value)
      Deprecated.
      Intrusive holders exist for legacy reasons only.
      Returns a new intrusive registry entry.

      This should not be called manually. Call Registry.entryOf(net.minecraft.util.registry.RegistryKey<T>) or Registry.getEntry(int) instead.

      Callers are responsible for filling the key later by calling

      invalid @link
      #setKeyAndValue
      .
      Returns:
      a new intrusive registry entry
      Mappings:
      Namespace Name Mixin selector
      official a Lgx$c;a(Lha;Ljava/lang/Object;)Lgx$c;
      intermediary method_40233 Lnet/minecraft/class_6880$class_6883;method_40233(Lnet/minecraft/class_7876;Ljava/lang/Object;)Lnet/minecraft/class_6880$class_6883;
      named intrusive Lnet/minecraft/util/registry/RegistryEntry$Reference;intrusive(Lnet/minecraft/class_7876;Ljava/lang/Object;)Lnet/minecraft/util/registry/RegistryEntry$Reference;
    • registryKey

      public RegistryKey<T> registryKey()
      Returns the registry key of this entry.
      Returns:
      the registry key of this entry
      Throws:
      IllegalStateException - if this is an intrusive entry and it is not initialized yet
      Mappings:
      Namespace Name Mixin selector
      official g Lgx$c;g()Laby;
      intermediary method_40237 Lnet/minecraft/class_6880$class_6883;method_40237()Lnet/minecraft/class_5321;
      named registryKey Lnet/minecraft/util/registry/RegistryEntry$Reference;registryKey()Lnet/minecraft/util/registry/RegistryKey;
    • value

      public T value()
      Specified by:
      value in interface RegistryEntry<T>
      Mappings:
      Namespace Name Mixin selector
      official a Lgx;a()Ljava/lang/Object;
      intermediary comp_349 Lnet/minecraft/class_6880;comp_349()Ljava/lang/Object;
      named value Lnet/minecraft/util/registry/RegistryEntry;value()Ljava/lang/Object;
    • 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
      official a Lgx;a(Labz;)Z
      intermediary method_40226 Lnet/minecraft/class_6880;method_40226(Lnet/minecraft/class_2960;)Z
      named matchesId Lnet/minecraft/util/registry/RegistryEntry;matchesId(Lnet/minecraft/util/Identifier;)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
      official a Lgx;a(Laby;)Z
      intermediary method_40225 Lnet/minecraft/class_6880;method_40225(Lnet/minecraft/class_5321;)Z
      named matchesKey Lnet/minecraft/util/registry/RegistryEntry;matchesKey(Lnet/minecraft/util/registry/RegistryKey;)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
      official a Lgx;a(Lamk;)Z
      intermediary method_40220 Lnet/minecraft/class_6880;method_40220(Lnet/minecraft/class_6862;)Z
      named isIn Lnet/minecraft/util/registry/RegistryEntry;isIn(Lnet/minecraft/tag/TagKey;)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
      official a Lgx;a(Ljava/util/function/Predicate;)Z
      intermediary method_40224 Lnet/minecraft/class_6880;method_40224(Ljava/util/function/Predicate;)Z
      named matches Lnet/minecraft/util/registry/RegistryEntry;matches(Ljava/util/function/Predicate;)Z
    • method_46745

      public boolean method_46745(class_7876<T> class_7876)
      Specified by:
      method_46745 in interface RegistryEntry<T>
      Mappings:
      Namespace Name Mixin selector
      official a Lgx;a(Lha;)Z
      intermediary method_46745 Lnet/minecraft/class_6880;method_46745(Lnet/minecraft/class_7876;)Z
      named method_46745 Lnet/minecraft/util/registry/RegistryEntry;method_46745(Lnet/minecraft/class_7876;)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
      official d Lgx;d()Lcom/mojang/datafixers/util/Either;
      intermediary method_40229 Lnet/minecraft/class_6880;method_40229()Lcom/mojang/datafixers/util/Either;
      named getKeyOrValue Lnet/minecraft/util/registry/RegistryEntry;getKeyOrValue()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
      official e Lgx;e()Ljava/util/Optional;
      intermediary method_40230 Lnet/minecraft/class_6880;method_40230()Ljava/util/Optional;
      named getKey Lnet/minecraft/util/registry/RegistryEntry;getKey()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
      official f Lgx;f()Lgx$b;
      intermediary method_40231 Lnet/minecraft/class_6880;method_40231()Lnet/minecraft/class_6880$class_6882;
      named getType Lnet/minecraft/util/registry/RegistryEntry;getType()Lnet/minecraft/util/registry/RegistryEntry$Type;
    • hasKeyAndValue

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

      void setRegistryKey(RegistryKey<T> registryKey)
      Mappings:
      Namespace Name Mixin selector
      official b Lgx$c;b(Laby;)V
      intermediary method_45917 Lnet/minecraft/class_6880$class_6883;method_45917(Lnet/minecraft/class_5321;)V
      named setRegistryKey Lnet/minecraft/util/registry/RegistryEntry$Reference;setRegistryKey(Lnet/minecraft/util/registry/RegistryKey;)V
    • setValue

      void setValue(T value)
      Mappings:
      Namespace Name Mixin selector
      official b Lgx$c;b(Ljava/lang/Object;)V
      intermediary method_45918 Lnet/minecraft/class_6880$class_6883;method_45918(Ljava/lang/Object;)V
      named setValue Lnet/minecraft/util/registry/RegistryEntry$Reference;setValue(Ljava/lang/Object;)V
    • setTags

      void setTags(Collection<TagKey<T>> tags)
      Mappings:
      Namespace Name Mixin selector
      official a Lgx$c;a(Ljava/util/Collection;)V
      intermediary method_40235 Lnet/minecraft/class_6880$class_6883;method_40235(Ljava/util/Collection;)V
      named setTags Lnet/minecraft/util/registry/RegistryEntry$Reference;setTags(Ljava/util/Collection;)V
    • 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
      official c Lgx;c()Ljava/util/stream/Stream;
      intermediary method_40228 Lnet/minecraft/class_6880;method_40228()Ljava/util/stream/Stream;
      named streamTags Lnet/minecraft/util/registry/RegistryEntry;streamTags()Ljava/util/stream/Stream;
    • toString

      public String toString()
      Overrides:
      toString in class Object