Package net.minecraft.resources
Class ResourceLocation
java.lang.Object
net.minecraft.resources.ResourceLocation
- All Implemented Interfaces:
Comparable<ResourceLocation>
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 a ResourceLocation
.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec
<ResourceLocation> static final String
static final com.mojang.brigadier.exceptions.SimpleCommandExceptionType
private final String
static final char
private final String
static final String
static final StreamCodec
<io.netty.buffer.ByteBuf, ResourceLocation> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
assertValidNamespace
(String pNamespace, String pPath) private static String
assertValidPath
(String pNamespace, String pPath) static ResourceLocation
bySeparator
(String pLocation, char pSeperator) int
int
compareTo
(ResourceLocation pOther) private static ResourceLocation
createUntrusted
(String pNamespace, String pPath) boolean
static ResourceLocation
fromNamespaceAndPath
(String pNamespace, String pPath) getPath()
int
hashCode()
static boolean
isAllowedInResourceLocation
(char pCharacter) static boolean
isValidNamespace
(String pNamespace) static boolean
isValidPath
(String pPath) static ResourceLocation
static ResourceLocation
read
(com.mojang.brigadier.StringReader p_135819_) static com.mojang.serialization.DataResult
<ResourceLocation> private static String
readGreedy
(com.mojang.brigadier.StringReader p_335690_) static ResourceLocation
readNonEmpty
(com.mojang.brigadier.StringReader p_336027_) toLanguageKey
(String pType) toLanguageKey
(String pType, String pKey) toString()
static ResourceLocation
static ResourceLocation
tryBySeparator
(String pLocation, char pSeperator) static ResourceLocation
Attempts to parse the specifiedlocation
as aResourceLocation
by splitting it into a namespace and path by a colon.static boolean
validNamespaceChar
(char pNamespaceChar) static boolean
validPathChar
(char pPathChar) static ResourceLocation
withDefaultNamespace
(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
-
ResourceLocation
-
-
Method Details
-
createUntrusted
-
fromNamespaceAndPath
-
parse
-
withDefaultNamespace
-
tryParse
Attempts to parse the specifiedlocation
as aResourceLocation
by splitting it into a namespace and path by a colon.If no colon is present in the
location
, the namespace defaults tominecraft
, taking thelocation
as the path.- Parameters:
pLocation
- the location string to try to parse as aResourceLocation
- Returns:
- the parsed resource location; otherwise
null
if 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:
compareTo
in interfaceComparable<ResourceLocation>
-
compareNamespaced
-
toDebugFileName
-
toLanguageKey
-
toShortLanguageKey
-
toLanguageKey
-
toLanguageKey
-
readGreedy
-
read
public static ResourceLocation read(com.mojang.brigadier.StringReader p_135819_) throws com.mojang.brigadier.exceptions.CommandSyntaxException - Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException
-
readNonEmpty
public static ResourceLocation readNonEmpty(com.mojang.brigadier.StringReader p_336027_) throws com.mojang.brigadier.exceptions.CommandSyntaxException - Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException
-
isAllowedInResourceLocation
public static boolean isAllowedInResourceLocation(char pCharacter) -
isValidPath
- Returns:
true
if the specifiedpath
is valid: consists only of[a-z0-9/._-]
characters
-
isValidNamespace
- Returns:
true
if the specifiednamespace
is valid: consists only of[a-z0-9_.-]
characters
-
assertValidNamespace
-
validPathChar
public static boolean validPathChar(char pPathChar) -
validNamespaceChar
public static boolean validNamespaceChar(char pNamespaceChar) -
assertValidPath
-