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 ResourceLocation
The location of the resource within the registry.private final ResourceLocation
The name of the parent registry of the resource.private static final ConcurrentMap
<ResourceKey.InternKey, ResourceKey<?>> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ResourceKey
(ResourceLocation pRegistryName, ResourceLocation 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>> p_195967_) int
compareTo
(ResourceKey<?> o) static <T> ResourceKey
<T> create
(ResourceKey<? extends Registry<T>> pRegistryKey, ResourceLocation pLocation) Constructs a newResourceKey
for a resource with the specifiedlocation
within the registry specified by the givenregistryKey
.private static <T> ResourceKey
<T> create
(ResourceLocation pRegistryName, ResourceLocation pLocation) static <T> ResourceKey
<Registry<T>> createRegistryKey
(ResourceLocation pLocation) boolean
isFor
(ResourceKey<? extends Registry<?>> pRegistryKey) location()
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. -
location
The location of the resource within the registry.
-
-
Constructor Details
-
ResourceKey
-
-
Method Details
-
codec
public static <T> com.mojang.serialization.Codec<ResourceKey<T>> codec(ResourceKey<? extends Registry<T>> p_195967_) -
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, ResourceLocation pLocation) Constructs a newResourceKey
for a resource with the specifiedlocation
within the registry specified by the givenregistryKey
.- Returns:
- the created resource key. The registry name is set to the location of the specified
registryKey
and with the specifiedlocation
as the location of the resource.
-
createRegistryKey
- Returns:
- the created registry key. The registry name is set to
minecraft:root
and the location the specifiedregistryName
.
-
create
private static <T> ResourceKey<T> create(ResourceLocation pRegistryName, ResourceLocation pLocation) -
toString
-
isFor
- Returns:
true
if this resource key is a direct child of the specifiedregistryKey
.
-
cast
-
location
-
registry
-
registryKey
-
compareTo
- Specified by:
compareTo
in interfaceComparable<T>
-