Class RegistryEntry.Reference<T>
- All Implemented Interfaces:
RegistryEntry<T>
- Direct Known Subclasses:
RegistryBuilder.LazyReferenceEntry
- 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
Registries.BLOCK,Registries.ITEM,Registries.FLUID,Registries.ENTITY_TYPE, andRegistries.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. 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 named net/minecraft/registry/entry/RegistryEntry$Referenceintermediary net/minecraft/class_6880$class_6883official jm$c
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumThe types of reference registry entries.Nested classes/interfaces inherited from interface net.minecraft.registry.entry.RegistryEntry
RegistryEntry.Direct<T>, RegistryEntry.Reference<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RegistryEntryOwner<T> private final RegistryEntry.Reference.Typeprivate @Nullable RegistryKey<T> private T -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedReference(RegistryEntry.Reference.Type referenceType, RegistryEntryOwner<T> owner, @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> intrusive(RegistryEntryOwner<T> owner, T value) 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.booleanmatches(RegistryEntry<T> entry) booleanmatchesId(Identifier id) Returns whether the ID of this entry isid.booleanmatchesKey(RegistryKey<T> key) Returns whether the registry key of this entry iskey.booleanownerEquals(RegistryEntryOwner<T> owner) Returns the registry key of this entry.(package private) voidsetRegistryKey(RegistryKey<T> registryKey) (package private) voidsetTags(Collection<TagKey<T>> tags) protected voidstatic <T> RegistryEntry.Reference<T> standAlone(RegistryEntryOwner<T> owner, 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()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.registry.entry.RegistryEntry
getIdAsString
-
Field Details
-
owner
- Mappings:
Namespace Name Mixin selector named ownerLnet/minecraft/registry/entry/RegistryEntry$Reference;owner:Lnet/minecraft/registry/entry/RegistryEntryOwner;intermediary field_40930Lnet/minecraft/class_6880$class_6883;field_40930:Lnet/minecraft/class_7876;official aLjm$c;a:Ljp;
-
tags
- Mappings:
Namespace Name Mixin selector named tagsLnet/minecraft/registry/entry/RegistryEntry$Reference;tags:Ljava/util/Set;intermediary field_36450Lnet/minecraft/class_6880$class_6883;field_36450:Ljava/util/Set;official bLjm$c;b:Ljava/util/Set;
-
referenceType
- Mappings:
Namespace Name Mixin selector named referenceTypeLnet/minecraft/registry/entry/RegistryEntry$Reference;referenceType:Lnet/minecraft/registry/entry/RegistryEntry$Reference$Type;intermediary field_36451Lnet/minecraft/class_6880$class_6883;field_36451:Lnet/minecraft/class_6880$class_6883$class_6884;official cLjm$c;c:Ljm$c$a;
-
registryKey
- Mappings:
Namespace Name Mixin selector named registryKeyLnet/minecraft/registry/entry/RegistryEntry$Reference;registryKey:Lnet/minecraft/registry/RegistryKey;intermediary field_36452Lnet/minecraft/class_6880$class_6883;field_36452:Lnet/minecraft/class_5321;official dLjm$c;d:Lakq;
-
value
- Mappings:
Namespace Name Mixin selector named valueLnet/minecraft/registry/entry/RegistryEntry$Reference;value:Ljava/lang/Object;intermediary field_36453Lnet/minecraft/class_6880$class_6883;field_36453:Ljava/lang/Object;official eLjm$c;e:Ljava/lang/Object;
-
-
Constructor Details
-
Reference
protected Reference(RegistryEntry.Reference.Type referenceType, RegistryEntryOwner<T> owner, @Nullable @Nullable RegistryKey<T> registryKey, @Nullable T value) - Mappings:
Namespace Name Mixin selector named <init>Lnet/minecraft/registry/entry/RegistryEntry$Reference;<init>(Lnet/minecraft/registry/entry/RegistryEntry$Reference$Type;Lnet/minecraft/registry/entry/RegistryEntryOwner;Lnet/minecraft/registry/RegistryKey;Ljava/lang/Object;)Vintermediary <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;)Vofficial <init>Ljm$c;<init>(Ljm$c$a;Ljp;Lakq;Ljava/lang/Object;)V
-
-
Method Details
-
standAlone
public static <T> RegistryEntry.Reference<T> standAlone(RegistryEntryOwner<T> owner, RegistryKey<T> registryKey) Returns a new stand-alone registry entry.This should not be called manually. Call
Registry.entryOf(net.minecraft.registry.RegistryKey<T>)orRegistry.getEntry(int)instead.Callers are responsible for filling the value later by calling
setValue(T).- Returns:
- a new stand-alone registry entry
- Mappings:
Namespace Name Mixin selector named standAloneLnet/minecraft/registry/entry/RegistryEntry$Reference;standAlone(Lnet/minecraft/registry/entry/RegistryEntryOwner;Lnet/minecraft/registry/RegistryKey;)Lnet/minecraft/registry/entry/RegistryEntry$Reference;intermediary method_40234Lnet/minecraft/class_6880$class_6883;method_40234(Lnet/minecraft/class_7876;Lnet/minecraft/class_5321;)Lnet/minecraft/class_6880$class_6883;official aLjm$c;a(Ljp;Lakq;)Ljm$c;
-
intrusive
@Deprecated public static <T> RegistryEntry.Reference<T> intrusive(RegistryEntryOwner<T> owner, @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.registry.RegistryKey<T>)orRegistry.getEntry(int)instead.Callers are responsible for filling the key later by calling
setRegistryKey(net.minecraft.registry.RegistryKey<T>).- Returns:
- a new intrusive registry entry
- Mappings:
Namespace Name Mixin selector named intrusiveLnet/minecraft/registry/entry/RegistryEntry$Reference;intrusive(Lnet/minecraft/registry/entry/RegistryEntryOwner;Ljava/lang/Object;)Lnet/minecraft/registry/entry/RegistryEntry$Reference;intermediary method_40233Lnet/minecraft/class_6880$class_6883;method_40233(Lnet/minecraft/class_7876;Ljava/lang/Object;)Lnet/minecraft/class_6880$class_6883;official aLjm$c;a(Ljp;Ljava/lang/Object;)Ljm$c;
-
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 named registryKeyLnet/minecraft/registry/entry/RegistryEntry$Reference;registryKey()Lnet/minecraft/registry/RegistryKey;intermediary method_40237Lnet/minecraft/class_6880$class_6883;method_40237()Lnet/minecraft/class_5321;official hLjm$c;h()Lakq;
-
value
- Specified by:
valuein interfaceRegistryEntry<T>- Mappings:
Namespace Name Mixin selector named valueLnet/minecraft/registry/entry/RegistryEntry;value()Ljava/lang/Object;intermediary comp_349Lnet/minecraft/class_6880;comp_349()Ljava/lang/Object;official aLjm;a()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 named matchesIdLnet/minecraft/registry/entry/RegistryEntry;matchesId(Lnet/minecraft/util/Identifier;)Zintermediary method_40226Lnet/minecraft/class_6880;method_40226(Lnet/minecraft/class_2960;)Zofficial aLjm;a(Lakr;)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 named matchesKeyLnet/minecraft/registry/entry/RegistryEntry;matchesKey(Lnet/minecraft/registry/RegistryKey;)Zintermediary method_40225Lnet/minecraft/class_6880;method_40225(Lnet/minecraft/class_5321;)Zofficial aLjm;a(Lakq;)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 named isInLnet/minecraft/registry/entry/RegistryEntry;isIn(Lnet/minecraft/registry/tag/TagKey;)Zintermediary method_40220Lnet/minecraft/class_6880;method_40220(Lnet/minecraft/class_6862;)Zofficial aLjm;a(Lawu;)Z
-
matches
- Specified by:
matchesin interfaceRegistryEntry<T>- Mappings:
Namespace Name Mixin selector named matchesLnet/minecraft/registry/entry/RegistryEntry;matches(Lnet/minecraft/registry/entry/RegistryEntry;)Zintermediary method_55838Lnet/minecraft/class_6880;method_55838(Lnet/minecraft/class_6880;)Zofficial aLjm;a(Ljm;)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 named matchesLnet/minecraft/registry/entry/RegistryEntry;matches(Ljava/util/function/Predicate;)Zintermediary method_40224Lnet/minecraft/class_6880;method_40224(Ljava/util/function/Predicate;)Zofficial aLjm;a(Ljava/util/function/Predicate;)Z
-
ownerEquals
- Specified by:
ownerEqualsin interfaceRegistryEntry<T>- Mappings:
Namespace Name Mixin selector named ownerEqualsLnet/minecraft/registry/entry/RegistryEntry;ownerEquals(Lnet/minecraft/registry/entry/RegistryEntryOwner;)Zintermediary method_46745Lnet/minecraft/class_6880;method_46745(Lnet/minecraft/class_7876;)Zofficial aLjm;a(Ljp;)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 named getKeyOrValueLnet/minecraft/registry/entry/RegistryEntry;getKeyOrValue()Lcom/mojang/datafixers/util/Either;intermediary method_40229Lnet/minecraft/class_6880;method_40229()Lcom/mojang/datafixers/util/Either;official dLjm;d()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 named getKeyLnet/minecraft/registry/entry/RegistryEntry;getKey()Ljava/util/Optional;intermediary method_40230Lnet/minecraft/class_6880;method_40230()Ljava/util/Optional;official eLjm;e()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 named getTypeLnet/minecraft/registry/entry/RegistryEntry;getType()Lnet/minecraft/registry/entry/RegistryEntry$Type;intermediary method_40231Lnet/minecraft/class_6880;method_40231()Lnet/minecraft/class_6880$class_6882;official fLjm;f()Ljm$b;
-
hasKeyAndValue
public boolean hasKeyAndValue()- Specified by:
hasKeyAndValuein interfaceRegistryEntry<T>- Mappings:
Namespace Name Mixin selector named hasKeyAndValueLnet/minecraft/registry/entry/RegistryEntry;hasKeyAndValue()Zintermediary method_40227Lnet/minecraft/class_6880;method_40227()Zofficial bLjm;b()Z
-
setRegistryKey
- Mappings:
Namespace Name Mixin selector named setRegistryKeyLnet/minecraft/registry/entry/RegistryEntry$Reference;setRegistryKey(Lnet/minecraft/registry/RegistryKey;)Vintermediary method_45917Lnet/minecraft/class_6880$class_6883;method_45917(Lnet/minecraft/class_5321;)Vofficial bLjm$c;b(Lakq;)V
-
setValue
- Mappings:
Namespace Name Mixin selector named setValueLnet/minecraft/registry/entry/RegistryEntry$Reference;setValue(Ljava/lang/Object;)Vintermediary method_45918Lnet/minecraft/class_6880$class_6883;method_45918(Ljava/lang/Object;)Vofficial bLjm$c;b(Ljava/lang/Object;)V
-
setTags
- Mappings:
Namespace Name Mixin selector named setTagsLnet/minecraft/registry/entry/RegistryEntry$Reference;setTags(Ljava/util/Collection;)Vintermediary method_40235Lnet/minecraft/class_6880$class_6883;method_40235(Ljava/util/Collection;)Vofficial aLjm$c;a(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 named streamTagsLnet/minecraft/registry/entry/RegistryEntry;streamTags()Ljava/util/stream/Stream;intermediary method_40228Lnet/minecraft/class_6880;method_40228()Ljava/util/stream/Stream;official cLjm;c()Ljava/util/stream/Stream;
-
toString
-