Class RegistryEntry.Reference<T>
- All Implemented Interfaces:
RegistryEntry<T>
- Enclosing interface:
RegistryEntry<T>
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, andRegistry.GAME_EVENTregistries. 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 setKeyAndValue(net.minecraft.util.registry.RegistryKey<T>, T). 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 ha$cintermediary net/minecraft/class_6880$class_6883named net/minecraft/util/registry/RegistryEntry$Reference
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enumThe types of reference registry entries.Nested classes/interfaces inherited from interface net.minecraft.util.registry.RegistryEntry
RegistryEntry.Direct<T>, RegistryEntry.Reference<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RegistryEntry.Reference.Typeprivate @Nullable RegistryKey<T>private T -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateReference(RegistryEntry.Reference.Type referenceType, Registry<T> registry, @Nullable RegistryKey<T> registryKey, T value) -
Method Summary
Modifier and TypeMethodDescriptiongetKey()Returns the registry key of this entry, or an empty optional if this is a direct entry.com.mojang.datafixers.util.Either<RegistryKey<T>,T> Returns the object that identifies this registry key.getType()Returns the type (direct or reference) of this registry entry.booleanstatic <T> RegistryEntry.Reference<T>Deprecated.Intrusive holders exist for legacy reasons only.booleanReturns whether this entry is intag.booleanmatches(Predicate<RegistryKey<T>> predicate) Returns whether this entry's key matchespredicate.booleanmatchesId(Identifier id) Returns whether the ID of this entry isid.booleanmatchesKey(RegistryKey<T> key) Returns whether the registry key of this entry iskey.booleanmatchesRegistry(Registry<T> registry) Returns whether the registry for the entry isregistry.Returns the registry key of this entry.(package private) voidsetKeyAndValue(RegistryKey<T> key, T value) Sets the key and the value of this registry entry.(package private) voidsetRegistryKey(RegistryKey<T> registryKey) (package private) voidsetTags(Collection<TagKey<T>> tags) (package private) voidstatic <T> RegistryEntry.Reference<T>standAlone(Registry<T> registry, RegistryKey<T> registryKey) Returns a new stand-alone registry entry.Returns a stream of the tags of this entry, or an empty stream if this is a direct entry.toString()value()
-
Field Details
-
registry
- Mappings:
Namespace Name Mixin selector official aLha$c;a:Lhl;intermediary field_36449Lnet/minecraft/class_6880$class_6883;field_36449:Lnet/minecraft/class_2378;named registryLnet/minecraft/util/registry/RegistryEntry$Reference;registry:Lnet/minecraft/util/registry/Registry;
-
tags
- Mappings:
Namespace Name Mixin selector official bLha$c;b:Ljava/util/Set;intermediary field_36450Lnet/minecraft/class_6880$class_6883;field_36450:Ljava/util/Set;named tagsLnet/minecraft/util/registry/RegistryEntry$Reference;tags:Ljava/util/Set;
-
referenceType
- Mappings:
Namespace Name Mixin selector official cLha$c;c:Lha$c$a;intermediary field_36451Lnet/minecraft/class_6880$class_6883;field_36451:Lnet/minecraft/class_6880$class_6883$class_6884;named referenceTypeLnet/minecraft/util/registry/RegistryEntry$Reference;referenceType:Lnet/minecraft/util/registry/RegistryEntry$Reference$Type;
-
registryKey
- Mappings:
Namespace Name Mixin selector official dLha$c;d:Labu;intermediary field_36452Lnet/minecraft/class_6880$class_6883;field_36452:Lnet/minecraft/class_5321;named registryKeyLnet/minecraft/util/registry/RegistryEntry$Reference;registryKey:Lnet/minecraft/util/registry/RegistryKey;
-
value
- Mappings:
Namespace Name Mixin selector official eLha$c;e:Ljava/lang/Object;intermediary field_36453Lnet/minecraft/class_6880$class_6883;field_36453:Ljava/lang/Object;named valueLnet/minecraft/util/registry/RegistryEntry$Reference;value:Ljava/lang/Object;
-
-
Constructor Details
-
Reference
private Reference(RegistryEntry.Reference.Type referenceType, Registry<T> registry, @Nullable @Nullable RegistryKey<T> registryKey, @Nullable T value) - Mappings:
Namespace Name Mixin selector official <init>Lha$c;<init>(Lha$c$a;Lhl;Labu;Ljava/lang/Object;)Vintermediary <init>Lnet/minecraft/class_6880$class_6883;<init>(Lnet/minecraft/class_6880$class_6883$class_6884;Lnet/minecraft/class_2378;Lnet/minecraft/class_5321;Ljava/lang/Object;)Vnamed <init>Lnet/minecraft/util/registry/RegistryEntry$Reference;<init>(Lnet/minecraft/util/registry/RegistryEntry$Reference$Type;Lnet/minecraft/util/registry/Registry;Lnet/minecraft/util/registry/RegistryKey;Ljava/lang/Object;)V
-
-
Method Details
-
standAlone
public static <T> RegistryEntry.Reference<T> standAlone(Registry<T> registry, 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>)orRegistry.getEntry(int)instead.Callers are responsible for filling the value later by calling
setKeyAndValue(net.minecraft.util.registry.RegistryKey<T>, T).- Returns:
- a new stand-alone registry entry
- Mappings:
Namespace Name Mixin selector official aLha$c;a(Lhl;Labu;)Lha$c;intermediary method_40234Lnet/minecraft/class_6880$class_6883;method_40234(Lnet/minecraft/class_2378;Lnet/minecraft/class_5321;)Lnet/minecraft/class_6880$class_6883;named standAloneLnet/minecraft/util/registry/RegistryEntry$Reference;standAlone(Lnet/minecraft/util/registry/Registry;Lnet/minecraft/util/registry/RegistryKey;)Lnet/minecraft/util/registry/RegistryEntry$Reference;
-
intrusive
@Deprecated public static <T> RegistryEntry.Reference<T> intrusive(Registry<T> registry, @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>)orRegistry.getEntry(int)instead.Callers are responsible for filling the key later by calling
setKeyAndValue(net.minecraft.util.registry.RegistryKey<T>, T).- Returns:
- a new intrusive registry entry
- Mappings:
Namespace Name Mixin selector official aLha$c;a(Lhl;Ljava/lang/Object;)Lha$c;intermediary method_40233Lnet/minecraft/class_6880$class_6883;method_40233(Lnet/minecraft/class_2378;Ljava/lang/Object;)Lnet/minecraft/class_6880$class_6883;named intrusiveLnet/minecraft/util/registry/RegistryEntry$Reference;intrusive(Lnet/minecraft/util/registry/Registry;Ljava/lang/Object;)Lnet/minecraft/util/registry/RegistryEntry$Reference;
-
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 gLha$c;g()Labu;intermediary method_40237Lnet/minecraft/class_6880$class_6883;method_40237()Lnet/minecraft/class_5321;named registryKeyLnet/minecraft/util/registry/RegistryEntry$Reference;registryKey()Lnet/minecraft/util/registry/RegistryKey;
-
value
- Specified by:
valuein interfaceRegistryEntry<T>- Mappings:
Namespace Name Mixin selector official aLha;a()Ljava/lang/Object;intermediary comp_349Lnet/minecraft/class_6880;comp_349()Ljava/lang/Object;named valueLnet/minecraft/util/registry/RegistryEntry;value()Ljava/lang/Object;
-
matchesId
Returns whether the ID of this entry isid.This always returns
falsefor direct entries.- Specified by:
matchesIdin interfaceRegistryEntry<T>- Returns:
- whether the ID of this entry is
id - Mappings:
Namespace Name Mixin selector official aLha;a(Labv;)Zintermediary method_40226Lnet/minecraft/class_6880;method_40226(Lnet/minecraft/class_2960;)Znamed matchesIdLnet/minecraft/util/registry/RegistryEntry;matchesId(Lnet/minecraft/util/Identifier;)Z
-
matchesKey
Returns whether the registry key of this entry iskey.This always returns
falsefor direct entries.- Specified by:
matchesKeyin interfaceRegistryEntry<T>- Returns:
- whether the registry key of this entry is
key - Mappings:
Namespace Name Mixin selector official aLha;a(Labu;)Zintermediary method_40225Lnet/minecraft/class_6880;method_40225(Lnet/minecraft/class_5321;)Znamed matchesKeyLnet/minecraft/util/registry/RegistryEntry;matchesKey(Lnet/minecraft/util/registry/RegistryKey;)Z
-
isIn
Returns whether this entry is intag.This always returns
falsefor direct entries, since tags are managed by a registry.- Specified by:
isInin interfaceRegistryEntry<T>- Returns:
- whether this entry is in
tag - Mappings:
Namespace Name Mixin selector official aLha;a(Lamg;)Zintermediary method_40220Lnet/minecraft/class_6880;method_40220(Lnet/minecraft/class_6862;)Znamed isInLnet/minecraft/util/registry/RegistryEntry;isIn(Lnet/minecraft/tag/TagKey;)Z
-
matches
Returns whether this entry's key matchespredicate.This always returns
falsefor direct entries.- Specified by:
matchesin interfaceRegistryEntry<T>- Returns:
- whether this entry's key matches
predicate - Mappings:
Namespace Name Mixin selector official aLha;a(Ljava/util/function/Predicate;)Zintermediary method_40224Lnet/minecraft/class_6880;method_40224(Ljava/util/function/Predicate;)Znamed matchesLnet/minecraft/util/registry/RegistryEntry;matches(Ljava/util/function/Predicate;)Z
-
matchesRegistry
Returns whether the registry for the entry isregistry.This always returns
truefor direct entries.- Specified by:
matchesRegistryin interfaceRegistryEntry<T>- Returns:
- whether the registry for the entry is
registry - Mappings:
Namespace Name Mixin selector official aLha;a(Lhl;)Zintermediary method_40222Lnet/minecraft/class_6880;method_40222(Lnet/minecraft/class_2378;)Znamed matchesRegistryLnet/minecraft/util/registry/RegistryEntry;matchesRegistry(Lnet/minecraft/util/registry/Registry;)Z
-
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:
getKeyOrValuein interfaceRegistryEntry<T>- Returns:
- the object that identifies this registry key
- Mappings:
Namespace Name Mixin selector official dLha;d()Lcom/mojang/datafixers/util/Either;intermediary method_40229Lnet/minecraft/class_6880;method_40229()Lcom/mojang/datafixers/util/Either;named getKeyOrValueLnet/minecraft/util/registry/RegistryEntry;getKeyOrValue()Lcom/mojang/datafixers/util/Either;
-
getKey
Returns the registry key of this entry, or an empty optional if this is a direct entry.- Specified by:
getKeyin interfaceRegistryEntry<T>- Returns:
- the registry key of this entry, or an empty optional if this is a direct entry
- Mappings:
Namespace Name Mixin selector official eLha;e()Ljava/util/Optional;intermediary method_40230Lnet/minecraft/class_6880;method_40230()Ljava/util/Optional;named getKeyLnet/minecraft/util/registry/RegistryEntry;getKey()Ljava/util/Optional;
-
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:
getTypein interfaceRegistryEntry<T>- Returns:
- the type (direct or reference) of this registry entry
- Mappings:
Namespace Name Mixin selector official fLha;f()Lha$b;intermediary method_40231Lnet/minecraft/class_6880;method_40231()Lnet/minecraft/class_6880$class_6882;named getTypeLnet/minecraft/util/registry/RegistryEntry;getType()Lnet/minecraft/util/registry/RegistryEntry$Type;
-
hasKeyAndValue
public boolean hasKeyAndValue()- Specified by:
hasKeyAndValuein interfaceRegistryEntry<T>- Mappings:
Namespace Name Mixin selector official bLha;b()Zintermediary method_40227Lnet/minecraft/class_6880;method_40227()Znamed hasKeyAndValueLnet/minecraft/util/registry/RegistryEntry;hasKeyAndValue()Z
-
setKeyAndValue
Sets the key and the value of this registry entry. When instantiated, an entry has only one of them, and this is called to fill the other value. Pass the current value for the parameter corresponding to the already filled field.- Throws:
IllegalStateException- when trying to change already filled fields- Mappings:
Namespace Name Mixin selector official aLha$c;a(Labu;Ljava/lang/Object;)Vintermediary method_40236Lnet/minecraft/class_6880$class_6883;method_40236(Lnet/minecraft/class_5321;Ljava/lang/Object;)Vnamed setKeyAndValueLnet/minecraft/util/registry/RegistryEntry$Reference;setKeyAndValue(Lnet/minecraft/util/registry/RegistryKey;Ljava/lang/Object;)V
-
setRegistryKey
- Mappings:
Namespace Name Mixin selector official bLha$c;b(Labu;)Vintermediary method_45917Lnet/minecraft/class_6880$class_6883;method_45917(Lnet/minecraft/class_5321;)Vnamed setRegistryKeyLnet/minecraft/util/registry/RegistryEntry$Reference;setRegistryKey(Lnet/minecraft/util/registry/RegistryKey;)V
-
setValue
- Mappings:
Namespace Name Mixin selector official bLha$c;b(Ljava/lang/Object;)Vintermediary method_45918Lnet/minecraft/class_6880$class_6883;method_45918(Ljava/lang/Object;)Vnamed setValueLnet/minecraft/util/registry/RegistryEntry$Reference;setValue(Ljava/lang/Object;)V
-
setTags
- Mappings:
Namespace Name Mixin selector official aLha$c;a(Ljava/util/Collection;)Vintermediary method_40235Lnet/minecraft/class_6880$class_6883;method_40235(Ljava/util/Collection;)Vnamed setTagsLnet/minecraft/util/registry/RegistryEntry$Reference;setTags(Ljava/util/Collection;)V
-
streamTags
Returns a stream of the tags of this entry, or an empty stream if this is a direct entry.- Specified by:
streamTagsin interfaceRegistryEntry<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 cLha;c()Ljava/util/stream/Stream;intermediary method_40228Lnet/minecraft/class_6880;method_40228()Ljava/util/stream/Stream;named streamTagsLnet/minecraft/util/registry/RegistryEntry;streamTags()Ljava/util/stream/Stream;
-
toString
-