Package net.minecraft.util.registry
Class RegistryKey<T>
java.lang.Object
net.minecraft.util.registry.RegistryKey<T>
- Type Parameters:
T- the type of the value
public class RegistryKey<T> extends Object
Represents a key for a value in a registry in a context where a
root registry is available.
- See Also:
Registry.ROOT
-
Field Summary
Fields Modifier and Type Field Description private static Map<String,RegistryKey<?>>INSTANCESA cache of all registry keys ever created.private IdentifierregistryThe identifier of the registry in the root registry.private IdentifiervalueThe identifier of the value in the registry specified byregistry. -
Constructor Summary
Constructors Modifier Constructor Description privateRegistryKey(Identifier registry, Identifier value) -
Method Summary
Modifier and Type Method Description static <T> Function<Identifier,RegistryKey<T>>createKeyFactory(RegistryKey<? extends Registry<T>> registry)Creates a function that converts an identifier to a registry key for the registry thatregistryrefers to in the root registry.IdentifiergetValue()booleanisOf(RegistryKey<? extends Registry<?>> registry)Returns whether this registry key belongs to the given registry (according to its type, not whether the registry actually contains this key).private static <T> RegistryKey<T>of(Identifier registry, Identifier value)static <T> RegistryKey<T>of(RegistryKey<? extends Registry<T>> registry, Identifier value)Creates a registry key for a value in a registry with a registry key for the value-holding registry in the root registry and an identifier of the value.static <T> RegistryKey<Registry<T>>ofRegistry(Identifier registry)Creates a registry key for a registry in the root registry (registry of all registries) with an identifier for the registry.StringtoString()
-
Field Details
-
INSTANCES
A cache of all registry keys ever created. -
registry
The identifier of the registry in the root registry. -
value
The identifier of the value in the registry specified byregistry.
-
-
Constructor Details
-
RegistryKey
-
-
Method Details
-
of
Creates a registry key for a value in a registry with a registry key for the value-holding registry in the root registry and an identifier of the value.You can call it like
RegistryKey.of(Registry.ITEM_KEY, new Identifier("iron_ingot"))to create a registry key for iron ingot.- Type Parameters:
T- the type of the value- Parameters:
registry- the registry key of the registry in the root registryvalue- the identifier of the value
-
ofRegistry
Creates a registry key for a registry in the root registry (registry of all registries) with an identifier for the registry.You can call it like
RegistryKey.of(new Identifier("block"))to create a registry key for the block registry.- Type Parameters:
T- the element type of the registry- Parameters:
registry- the identifier of the registry
-
of
-
toString
-
isOf
Returns whether this registry key belongs to the given registry (according to its type, not whether the registry actually contains this key).- Parameters:
registry- the key of the registry that this registry key should be inside
-
getValue
-
createKeyFactory
public static <T> Function<Identifier,RegistryKey<T>> createKeyFactory(RegistryKey<? extends Registry<T>> registry)Creates a function that converts an identifier to a registry key for the registry thatregistryrefers to in the root registry.- Parameters:
registry- the reference to the value-holding registry in the root registry
-