CLASS net/minecraft/class_2960 net/minecraft/util/Identifier COMMENT An identifier used to identify things. This is also known as "resource location", COMMENT "namespaced ID", "location", or just "ID". This is a non-typed immutable object, COMMENT and identifies things using a combination of namespace and path. Identifiers should COMMENT always be compared using {@link #equals} method, not {@code ==}. COMMENT COMMENT

Format

COMMENT

Identifiers are formatted as {@code :}. If the namespace and colon COMMENT are omitted, the namespace defaults to {@value #DEFAULT_NAMESPACE}. COMMENT COMMENT

The namespace and path must contain only ASCII lowercase letters ({@code COMMENT [a-z]}), ASCII digits ({@code [0-9]}), or the characters {@code _}, {@code .}, and COMMENT {@code -}. The path can also contain the standard path separator {@code COMMENT /}. Uppercase letters cannot be used. {@link #isValid} can be used to check whether a COMMENT string is a valid identifier. When handling externally provided identifiers, it should COMMENT either validate or use {@link #tryParse} instead of the constructor. Another common COMMENT mistake is using a formatted string with {@code %d} or {@code %f} to construct an COMMENT identifier without specifying the locate explicitly, as they are not guaranteed to be COMMENT ASCII digits in certain locales. Use {@link String#format(Locale, String, Object[])} COMMENT with {@link java.util.Locale#ROOT} instead of {@link String#formatted}. COMMENT COMMENT

Namespace

COMMENT

The namespace of an identifier identifies the origin of the thing. COMMENT For example, two mods to the game could both add an item with the ID "orange"; COMMENT the namespace is used to differentiate the two. (The convention is to use the ID COMMENT assigned to the mod as the namespace.) COMMENT COMMENT

A namespace only determines the source of an identifier, and does not determine its purpose; so long as COMMENT two identifiers are used for different purposes, they can share the namespace and path. COMMENT For example, the identifier {@code minecraft:dirt} is shared by blocks and items. COMMENT There is no need to change the identifier to, say, {@code minecraft_block:dirt} or COMMENT {@code minecraft_item:dirt}. COMMENT COMMENT

Several namespaces are reserved for vanilla use. While those identifiers can be used for COMMENT referencing and overwriting vanilla things, it is highly discouraged to use them to COMMENT identify your own, new things. For example, a modded block or a new biome added by COMMENT data packs should not use the reserved namespaces, but it's fine to use them when COMMENT modifying an existing biome under that namespace. The reserved namespaces are COMMENT {@value #DEFAULT_NAMESPACE}, {@code brigadier}, and {@value #REALMS_NAMESPACE}. COMMENT {@value #DEFAULT_NAMESPACE} is also the default namespace used when no namespace is COMMENT provided. COMMENT COMMENT

Path

COMMENT

The path of the identifier identifies the thing within the namespace, such as COMMENT between different items from the same mod. Additionally, this is sometimes used to COMMENT refer to a file path, such as in textures. COMMENT COMMENT

Creation

COMMENT

There are many ways to create a new identifier: COMMENT COMMENT

COMMENT COMMENT

Using Identifier

COMMENT

Identifiers identify several objects in the game. {@link COMMENT net.minecraft.registry.Registry} holds objects, such as blocks and items, that are COMMENT identified by an identifier. Textures are also identified using an identifier; such COMMENT an identifier is represented as a file path with an extension, such as {@code COMMENT minecraft:textures/entity/pig/pig.png}. COMMENT COMMENT

The string representation of the identifier ({@code :}) can be COMMENT obtained by calling {@link #toString}. This always includes the namespace. An identifier COMMENT can be converted to a translation key using {@link #toTranslationKey(String)} method. COMMENT COMMENT

RegistryKey

COMMENT

Identifier is not type-aware; {@code minecraft:tnt} could refer to a TNT block, a TNT COMMENT item, or a TNT entity. To identify a registered object uniquely, {@link COMMENT net.minecraft.registry.RegistryKey} can be used. A registry key is a combination COMMENT of the registry's identifier and the object's identifier. FIELD field_13353 namespace Ljava/lang/String; FIELD field_13354 COMMAND_EXCEPTION Lcom/mojang/brigadier/exceptions/SimpleCommandExceptionType; FIELD field_13355 path Ljava/lang/String; FIELD field_25139 CODEC Lcom/mojang/serialization/Codec; FIELD field_33380 NAMESPACE_SEPARATOR C FIELD field_33381 DEFAULT_NAMESPACE Ljava/lang/String; FIELD field_33382 REALMS_NAMESPACE Ljava/lang/String; FIELD field_48267 PACKET_CODEC Lnet/minecraft/class_9139; METHOD (Ljava/lang/String;)V COMMENT

Takes a string of the form {@code :} or {@code } which will use the default namespace, for example {@code minecraft:iron_ingot} or {@code iron_ingot}. COMMENT

The string will be split (on the {@code :}) into an identifier with the specified path and namespace. COMMENT Prefer using the {@link net.minecraft.util.Identifier#Identifier(java.lang.String, java.lang.String) Identifier(java.lang.String, java.lang.String)} constructor that takes the namespace and path as individual parameters to avoid mistakes. COMMENT

If there is no colon in the given string argument, the namespace will be set to {@value #DEFAULT_NAMESPACE}, and the path will be the given argument. COMMENT If the colon is the first character of the given string argument (i.e. the namespace is empty), the namespace will also be set to {@value #DEFAULT_NAMESPACE}, and the path will be the given argument without the initial colon. COMMENT @throws InvalidIdentifierException if the string cannot be parsed as an identifier. ARG 1 id METHOD (Ljava/lang/String;Ljava/lang/String;)V ARG 1 namespace ARG 2 path METHOD (Ljava/lang/String;Ljava/lang/String;Lnet/minecraft/class_2960$class_7658;)V ARG 1 namespace ARG 2 path ARG 3 extraData METHOD ([Ljava/lang/String;)V ARG 1 id METHOD compareTo (Ljava/lang/Object;)I ARG 1 other METHOD equals (Ljava/lang/Object;)Z ARG 1 o METHOD method_12829 tryParse (Ljava/lang/String;)Lnet/minecraft/class_2960; COMMENT {@return {@code id} parsed as an identifier, or {@code null} if it cannot be parsed} COMMENT COMMENT @see #of ARG 0 id METHOD method_12830 split (Ljava/lang/String;C)[Ljava/lang/String; COMMENT Splits the {@code id} into an array of two strings at the first occurrence of {@code delimiter}, excluding the delimiter character, or uses {@value #DEFAULT_NAMESPACE} for the first string in the resulting array when the deliminator does not exist or is the first character. ARG 0 id ARG 1 delimiter METHOD method_12831 isCharValid (C)Z ARG 0 c METHOD method_12832 getPath ()Ljava/lang/String; COMMENT {@return the path of the identifier} METHOD method_12835 fromCommandInput (Lcom/mojang/brigadier/StringReader;)Lnet/minecraft/class_2960; ARG 0 reader METHOD method_12836 getNamespace ()Ljava/lang/String; COMMENT {@return the namespace of the identifier} COMMENT COMMENT

This returns {@value #DEFAULT_NAMESPACE} for identifiers created without a namespace. METHOD method_12838 splitOn (Ljava/lang/String;C)Lnet/minecraft/class_2960; ARG 0 id ARG 1 delimiter METHOD method_20207 isValid (Ljava/lang/String;)Z COMMENT {@return whether {@code id} can be parsed as an identifier} ARG 0 id METHOD method_20208 isPathValid (Ljava/lang/String;)Z COMMENT {@return whether {@code path} can be used as an identifier's path} ARG 0 path METHOD method_20209 isNamespaceValid (Ljava/lang/String;)Z COMMENT {@return whether {@code namespace} can be used as an identifier's namespace} ARG 0 namespace METHOD method_29184 isPathCharacterValid (C)Z COMMENT {@return whether {@code character} is valid for use in identifier paths} ARG 0 character METHOD method_29185 isNamespaceCharacterValid (C)Z COMMENT {@return whether {@code character} is valid for use in identifier namespaces} ARG 0 character METHOD method_29186 validate (Ljava/lang/String;)Lcom/mojang/serialization/DataResult; ARG 0 id METHOD method_36181 toUnderscoreSeparatedString ()Ljava/lang/String; COMMENT {@return the string representation of the identifier with slashes and colons replaced COMMENT with underscores} METHOD method_42093 toTranslationKey (Ljava/lang/String;)Ljava/lang/String; COMMENT {@return the {@linkplain #toTranslationKey() long translation key} prefixed with COMMENT {@code prefix} and a dot} ARG 1 prefix METHOD method_42094 toTranslationKey ()Ljava/lang/String; COMMENT {@return the long translation key, without omitting the default namespace} METHOD method_43902 of (Ljava/lang/String;Ljava/lang/String;)Lnet/minecraft/class_2960; COMMENT {@return an identifier from the provided {@code namespace} and {@code path}, or COMMENT {@code null} if either argument is invalid} COMMENT COMMENT @see #tryParse ARG 0 namespace ARG 1 path METHOD method_43903 toShortTranslationKey ()Ljava/lang/String; COMMENT {@return the short translation key, with the default namespace omitted if present} METHOD method_45134 withPath (Ljava/util/function/UnaryOperator;)Lnet/minecraft/class_2960; ARG 1 pathFunction METHOD method_45135 validateNamespace (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; ARG 0 namespace ARG 1 path METHOD method_45136 withPath (Ljava/lang/String;)Lnet/minecraft/class_2960; ARG 1 path METHOD method_45137 validatePath (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; ARG 0 namespace ARG 1 path METHOD method_45138 withPrefixedPath (Ljava/lang/String;)Lnet/minecraft/class_2960; ARG 1 prefix METHOD method_48331 withSuffixedPath (Ljava/lang/String;)Lnet/minecraft/class_2960; ARG 1 suffix METHOD method_48747 toTranslationKey (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; COMMENT {@return the {@linkplain #toTranslationKey() long translation key} prefixed with COMMENT {@code prefix} and a dot, and suffixed with a dot and {@code suffix}} ARG 1 prefix ARG 2 suffix METHOD method_58274 fromCommandInputNonEmpty (Lcom/mojang/brigadier/StringReader;)Lnet/minecraft/class_2960; ARG 0 reader METHOD method_58275 readString (Lcom/mojang/brigadier/StringReader;)Ljava/lang/String; ARG 0 reader CLASS class_2961 Serializer METHOD deserialize (Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Ljava/lang/Object; ARG 1 json ARG 2 type ARG 3 context METHOD serialize (Ljava/lang/Object;Ljava/lang/reflect/Type;Lcom/google/gson/JsonSerializationContext;)Lcom/google/gson/JsonElement; ARG 1 id ARG 2 type ARG 3 context CLASS class_7658 ExtraData COMMENT A piece of extra data that a subclass may attach to an identifier. This is COMMENT not used by {@link Identifier} itself.