public class Identifier extends Object implements Comparable<Identifier>
Modifier and Type | Class and Description |
---|---|
static class |
Identifier.Serializer |
Modifier and Type | Field and Description |
---|---|
static com.mojang.serialization.Codec<Identifier> |
CODEC |
private static com.mojang.brigadier.exceptions.SimpleCommandExceptionType |
COMMAND_EXCEPTION |
protected String |
namespace |
protected String |
path |
Modifier | Constructor and Description |
---|---|
|
Identifier(String id)
Takes a string of the form
<namespace>:<path> , for example minecraft:iron_ingot . |
protected |
Identifier(String[] id) |
|
Identifier(String namespace,
String path) |
Modifier and Type | Method and 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 an
Identifier . |
public static final com.mojang.serialization.Codec<Identifier> CODEC
private static final com.mojang.brigadier.exceptions.SimpleCommandExceptionType COMMAND_EXCEPTION
protected final String namespace
protected final String path
protected Identifier(String[] id)
public Identifier(String id)
Takes a string of the form <namespace>:<path>
, for example minecraft:iron_ingot
.
The string will be split (on 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.InvalidIdentifierException
- if the string cannot be parsed as an identifier.public static Identifier splitOn(String id, char delimiter)
@Nullable public static Identifier tryParse(String id)
Parses a string into an Identifier
.
<namespace>:<path>
, for example minecraft:iron_ingot
.null
if the string couldn't be parsed as an identifierprivate static com.mojang.serialization.DataResult<Identifier> method_29186(String string)
public String getPath()
public String getNamespace()
public int compareTo(Identifier identifier)
compareTo
in interface Comparable<Identifier>
public static Identifier fromCommandInput(com.mojang.brigadier.StringReader reader) throws com.mojang.brigadier.exceptions.CommandSyntaxException
com.mojang.brigadier.exceptions.CommandSyntaxException
public static boolean isCharValid(char c)
private static boolean isPathValid(String path)
private static boolean isNamespaceValid(String namespace)
public static boolean isPathCharacterValid(char char2)
private static boolean isNamespaceCharacterValid(char char2)
@Environment(value=CLIENT) public static boolean isValid(String id)