Package net.minecraft.resources
Class ResourceKey<T>
java.lang.Object
net.minecraft.resources.ResourceKey<T>
- Type Parameters:
T- The type of the resource represented by thisResourceKey, or the type of the registry if it is a registry key.
- All Implemented Interfaces:
Comparable<ResourceKey<?>>
An immutable key for a resource, in terms of the name of its parent registry and its location in that registry.
Registry uses this to return resource keys for registry objects via Registry.getResourceKey(Object). It also uses this class to store its name, with the parent registry name set to minecraft:root. When used in this way it is usually referred to as a "registry key".
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Identifierprivate final IdentifierThe name of the parent registry of the resource.private static final ConcurrentMap<ResourceKey.InternKey, ResourceKey<?>> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateResourceKey(Identifier pRegistryName, Identifier pLocation) -
Method Summary
Modifier and TypeMethodDescription<E> Optional<ResourceKey<E>> cast(ResourceKey<? extends Registry<E>> pRegistryKey) static <T> com.mojang.serialization.Codec<ResourceKey<T>> codec(ResourceKey<? extends Registry<T>> pRegistryKey) intcompareTo(ResourceKey<?> o) private static <T> ResourceKey<T> create(Identifier pRegistryName, Identifier pLocation) static <T> ResourceKey<T> create(ResourceKey<? extends Registry<T>> pRegistryKey, Identifier pLocation) Constructs a newResourceKeyfor a resource with the specifiedlocationwithin the registry specified by the givenregistryKey.static <T> ResourceKey<Registry<T>> createRegistryKey(Identifier pLocation) booleanisFor(ResourceKey<? extends Registry<?>> pRegistryKey) registry()static <T> StreamCodec<io.netty.buffer.ByteBuf, ResourceKey<T>> streamCodec(ResourceKey<? extends Registry<T>> pRegistryKey) toString()
-
Field Details
-
VALUES
-
registryName
The name of the parent registry of the resource. -
identifier
-
-
Constructor Details
-
ResourceKey
-
-
Method Details
-
codec
public static <T> com.mojang.serialization.Codec<ResourceKey<T>> codec(ResourceKey<? extends Registry<T>> pRegistryKey) -
streamCodec
public static <T> StreamCodec<io.netty.buffer.ByteBuf,ResourceKey<T>> streamCodec(ResourceKey<? extends Registry<T>> pRegistryKey) -
create
public static <T> ResourceKey<T> create(ResourceKey<? extends Registry<T>> pRegistryKey, Identifier pLocation) Constructs a newResourceKeyfor a resource with the specifiedlocationwithin the registry specified by the givenregistryKey.- Returns:
- the created resource key. The registry name is set to the location of the specified
registryKeyand with the specifiedlocationas the location of the resource.
-
createRegistryKey
- Returns:
- the created registry key. The registry name is set to
minecraft:rootand the location the specifiedregistryName.
-
create
-
toString
-
isFor
- Returns:
trueif this resource key is a direct child of the specifiedregistryKey.
-
cast
-
identifier
-
registry
-
registryKey
-
compareTo
- Specified by:
compareToin interfaceComparable<T>
-