Package net.minecraft.resources
Class Identifier
java.lang.Object
net.minecraft.resources.Identifier
- All Implemented Interfaces:
Comparable<Identifier>
An immutable location of a resource, in terms of a path and namespace.
This is used as an identifier for a resource, usually for those housed in a Registry, such as blocks and items.
minecraft is always taken as the default namespace for a resource location when none is explicitly stated. When using this for registering objects, this namespace should only be used for resources added by Minecraft itself.
Generally, and by the implementation of toString(), the string representation of this class is expressed in the form namespace:path. The colon is also used as the default separator for parsing strings as an Identifier.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<Identifier> static final Stringstatic final com.mojang.brigadier.exceptions.SimpleCommandExceptionTypeprivate final Stringstatic final charprivate final Stringstatic final Stringstatic final StreamCodec<io.netty.buffer.ByteBuf, Identifier> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringassertValidNamespace(String pNamespace, String pPath) private static StringassertValidPath(String pNamespace, String pPath) static IdentifierbySeparator(String pLocation, char pSeparator) intintcompareTo(Identifier pOther) private static IdentifiercreateUntrusted(String pNamespace, String pPath) booleanstatic IdentifierfromNamespaceAndPath(String pNamespace, String pPath) getPath()inthashCode()static booleanisAllowedInIdentifier(char pC) static booleanisValidNamespace(String pNamespace) static booleanisValidPath(String pPath) static Identifierstatic Identifierread(com.mojang.brigadier.StringReader pReader) static com.mojang.serialization.DataResult<Identifier> private static StringreadGreedy(com.mojang.brigadier.StringReader pReader) static IdentifierreadNonEmpty(com.mojang.brigadier.StringReader pReader) toLanguageKey(String pType) toLanguageKey(String pType, String pKey) toString()static @Nullable Identifierstatic @Nullable IdentifiertryBySeparator(String pLocation, char pSeperator) static @Nullable IdentifierAttempts to parse the specifiedlocationas aResourceLocationby splitting it into a namespace and path by a colon.static booleanvalidNamespaceChar(char pNamespaceChar) static booleanvalidPathChar(char pPathChar) static IdentifierwithDefaultNamespace(String pLocation) withPath(UnaryOperator<String> pPathOperator) withPrefix(String pPathPrefix) withSuffix(String pPathSuffix)
-
Field Details
-
CODEC
-
STREAM_CODEC
-
ERROR_INVALID
public static final com.mojang.brigadier.exceptions.SimpleCommandExceptionType ERROR_INVALID -
NAMESPACE_SEPARATOR
public static final char NAMESPACE_SEPARATOR- See Also:
-
DEFAULT_NAMESPACE
- See Also:
-
REALMS_NAMESPACE
- See Also:
-
namespace
-
path
-
-
Constructor Details
-
Identifier
-
-
Method Details
-
createUntrusted
-
fromNamespaceAndPath
-
parse
-
withDefaultNamespace
-
tryParse
Attempts to parse the specifiedlocationas aResourceLocationby splitting it into a namespace and path by a colon.If no colon is present in the
location, the namespace defaults tominecraft, taking thelocationas the path.- Parameters:
pLocation- the location string to try to parse as aResourceLocation- Returns:
- the parsed resource location; otherwise
nullif there is a non[a-z0-9_.-]character in the decomposed namespace or a non[a-z0-9/._-]character in the decomposed path - See Also:
-
tryBuild
-
bySeparator
-
tryBySeparator
-
read
-
getPath
-
getNamespace
-
withPath
-
withPath
-
withPrefix
-
withSuffix
-
toString
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<Identifier>
-
compareNamespaced
-
toDebugFileName
-
toLanguageKey
-
toShortLanguageKey
-
toShortString
-
toLanguageKey
-
toLanguageKey
-
readGreedy
-
read
public static Identifier read(com.mojang.brigadier.StringReader pReader) throws com.mojang.brigadier.exceptions.CommandSyntaxException - Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException
-
readNonEmpty
public static Identifier readNonEmpty(com.mojang.brigadier.StringReader pReader) throws com.mojang.brigadier.exceptions.CommandSyntaxException - Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException
-
isAllowedInIdentifier
public static boolean isAllowedInIdentifier(char pC) -
isValidPath
- Returns:
trueif the specifiedpathis valid: consists only of[a-z0-9/._-]characters
-
isValidNamespace
- Returns:
trueif the specifiednamespaceis valid: consists only of[a-z0-9_.-]characters
-
assertValidNamespace
-
validPathChar
public static boolean validPathChar(char pPathChar) -
validNamespaceChar
public static boolean validNamespaceChar(char pNamespaceChar) -
assertValidPath
-