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 '/'.
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<Identifier> CODEC
    • COMMAND_EXCEPTION

      private static final com.mojang.brigadier.exceptions.SimpleCommandExceptionType COMMAND_EXCEPTION
    • namespace

      protected final String namespace
    • path

      protected final String path
  • Constructor Details

    • Identifier

      protected Identifier​(String[] id)
    • Identifier

      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.

      Prefer using the 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

      public Identifier​(String namespace, String path)
  • Method Details

    • splitOn

      public static Identifier splitOn​(String id, char delimiter)
    • tryParse

      @Nullable public static Identifier tryParse​(String id)

      Parses a string into an Identifier.

      Takes a string of the form <namespace>:<path>, for example minecraft:iron_ingot.
      Returns:
      resulting identifier, or null if the string couldn't be parsed as an identifier
    • split

      protected static String[] split​(String id, char delimiter)
    • method_29186

      private static com.mojang.serialization.DataResult<Identifier> method_29186​(String string)
    • getPath

      public String getPath()
    • getNamespace

      public String getNamespace()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals​(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo​(Identifier identifier)
      Specified by:
      compareTo in interface Comparable<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

      private static boolean isPathValid​(String path)
    • isNamespaceValid

      private static boolean isNamespaceValid​(String namespace)
    • isPathCharacterValid

      public static boolean isPathCharacterValid​(char char2)
    • isNamespaceCharacterValid

      private static boolean isNamespaceCharacterValid​(char char2)
    • isValid

      @Environment(CLIENT) public static boolean isValid​(String id)