Package net.minecraft.util
Class Identifier
java.lang.Object
net.minecraft.util.Identifier
- All Implemented Interfaces:
Comparable<Identifier>
- Direct Known Subclasses:
ModelIdentifier
public class Identifier extends Object implements Comparable<Identifier>
The namespace and path must contain only lowercase letters ([a-z]), digits ([0-9]), or the characters '_', '.', and '-'. The path can also contain the standard path separator '/'.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Identifier.Serializer
-
Field Summary
Fields Modifier and Type Field Description static com.mojang.serialization.Codec<Identifier>
CODEC
private static com.mojang.brigadier.exceptions.SimpleCommandExceptionType
COMMAND_EXCEPTION
protected String
namespace
protected String
path
-
Constructor Summary
Constructors Modifier Constructor Description Identifier(String id)
Takes a string of the form<namespace>:<path>
, for exampleminecraft:iron_ingot
.protected
Identifier(String[] id)
Identifier(String namespace, String path)
-
Method Summary
Modifier and Type Method Description int
compareTo(Identifier identifier)
boolean
equals(Object object)
static Identifier
fromCommandInput(com.mojang.brigadier.StringReader reader)
String
getNamespace()
String
getPath()
int
hashCode()
static boolean
isCharValid(char c)
private static boolean
isNamespaceCharacterValid(char char2)
private static boolean
isNamespaceValid(String namespace)
static boolean
isPathCharacterValid(char char2)
private static boolean
isPathValid(String path)
static boolean
isValid(String id)
private static com.mojang.serialization.DataResult<Identifier>
method_29186(String string)
protected static String[]
split(String id, char delimiter)
static Identifier
splitOn(String id, char delimiter)
String
toString()
static Identifier
tryParse(String id)
Parses a string into anIdentifier
.
-
Field Details
-
CODEC
-
COMMAND_EXCEPTION
private static final com.mojang.brigadier.exceptions.SimpleCommandExceptionType COMMAND_EXCEPTION -
namespace
-
path
-
-
Constructor Details
-
Identifier
-
Identifier
Takes a string of the form
<namespace>:<path>
, for exampleminecraft:iron_ingot
.The string will be split (on the
Prefer using the:
) into an identifier with the specified path and namespace.Identifier(java.lang.String, java.lang.String)
constructor that takes the namespace and path as individual parameters to avoid mistakes.- Throws:
InvalidIdentifierException
- if the string cannot be parsed as an identifier.
-
Identifier
-
-
Method Details
-
splitOn
-
tryParse
Parses a string into an
Takes a string of the formIdentifier
.<namespace>:<path>
, for exampleminecraft:iron_ingot
.- Returns:
- resulting identifier, or
null
if the string couldn't be parsed as an identifier
-
split
-
method_29186
-
getPath
-
getNamespace
-
toString
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<Identifier>
-
fromCommandInput
public static Identifier fromCommandInput(com.mojang.brigadier.StringReader reader) throws com.mojang.brigadier.exceptions.CommandSyntaxException- Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException
-
isCharValid
public static boolean isCharValid(char c) -
isPathValid
-
isNamespaceValid
-
isPathCharacterValid
public static boolean isPathCharacterValid(char char2) -
isNamespaceCharacterValid
private static boolean isNamespaceCharacterValid(char char2) -
isValid
-