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 ResourceLocationThe location of the resource within the registry.private final ResourceLocationThe name of the parent registry of the resource.private static final ConcurrentMap<ResourceKey.InternKey, ResourceKey<?>> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateResourceKey(ResourceLocation registryName, ResourceLocation location) -
Method Summary
Modifier and TypeMethodDescription<E> Optional<ResourceKey<E>> cast(ResourceKey<? extends Registry<E>> registryKey) static <T> com.mojang.serialization.Codec<ResourceKey<T>> codec(ResourceKey<? extends Registry<T>> registryKey) intcompareTo(ResourceKey<?> o) static <T> ResourceKey<T> create(ResourceKey<? extends Registry<T>> registryKey, ResourceLocation location) Constructs a newResourceKeyfor a resource with the specifiedlocationwithin the registry specified by the givenregistryKey.private static <T> ResourceKey<T> create(ResourceLocation registryName, ResourceLocation location) static <T> ResourceKey<Registry<T>> createRegistryKey(ResourceLocation location) booleanisFor(ResourceKey<? extends Registry<?>> registryKey) location()registry()static <T> StreamCodec<io.netty.buffer.ByteBuf, ResourceKey<T>> streamCodec(ResourceKey<? extends Registry<T>> registryKey) 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>> registryKey) -
streamCodec
public static <T> StreamCodec<io.netty.buffer.ByteBuf,ResourceKey<T>> streamCodec(ResourceKey<? extends Registry<T>> registryKey) -
create
public static <T> ResourceKey<T> create(ResourceKey<? extends Registry<T>> registryKey, ResourceLocation location) 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
-
location
-
registry
-
registryKey
-
compareTo
- Specified by:
compareToin interfaceComparable<T>
-