'''Resource locations'''Officially named '''resource location''' {{in|java}}. However, this name isn't used {{in|bedrock}}. (also known as '''namespaced IDs''', '''namespaced identifiers''', '''resource identifiers''',{{snap|19w39a|September 27, 2019}} or '''namespaced strings'''[https://github.com/Mojang/DataFixerUpper/blob/8b5f82ab78b30ff5813b3a7f3906cd3f4f732acf/src/main/java/com/mojang/datafixers/types/constant/NamespacedStringType.java DataFixerUpper/NamespacedStringType.java at 8b5f82ab78b30ff5813b3a7f3906cd3f4f732acf · Mojang/DataFixerUpper] – GitHub) are a way to declare and specify game objects in ''Minecraft'', which can identify built-in and user-defined objects without potential ambiguity or conflicts.
== Introduction ==
Resource locations are used as plain strings to reference [[block]]s, [[item]]s, [[Entity#Types of entities|entity types]], and various other objects in vanilla ''Minecraft''.
A valid resource location has a format of namespace:path
, where only certain characters can be used.
=== Legal characters ===
==== Java Edition ====
The namespace and the path of a resource location should only contain the following symbols:
* 0123456789
Numbers
* abcdefghijklmnopqrstuvwxyz
Lowercase letters
* _
Underscore
* -
Hyphen/minus
* .
Dot
The following characters are illegal in the namespace, but acceptable in the path:
* /
Forward slash (directory separator)
The preferred naming convention for either namespace or path is snake_case
.
==== Bedrock Edition ====
The namespace and the path of an namespaced ID can contain all symbols with the exception of slashes and colons.
The following characters are illegal in the namespace, but acceptable in the path of '''loot tables and functions'''.
* /
Forward slash (directory separator)
The preferred naming convention for either namespace or path is snake_case
.
=== Conversion to string ===
A resource location would be converted to a string by appending its namespace with a :
(colon) and its path.
Examples:
{| class="wikitable"
|-
! Namespace !! Path !! String representation
|-
| minecraft
|| diamond
|| minecraft:diamond
|-
| foo
|| bar.baz
|| foo:bar.baz
|-
| minecraftwiki
|| commands/minecraft_wiki
|| minecraftwiki:commands/minecraft_wiki
|}
=== Conversion from string ===
All resource locations are able to be converted to strings. However not all strings are able to be converted to resource locations
For a string to be converted, it must follow these restrictions:
* The string may have at most one :
(colon) character
* The rest of the string must fulfill the requirement for [[#Legal characters|legal characters]]. This includes disallowing /
(forward slash) characters before the :
, if a :
is present
When the :
is present, the part of the string before the :
becomes the namespace, and the part of the string after the :
becomes the path.
{{IN|java}}, and in some cases {{in|bedrock}}, when the :
is absent, [[#minecraft namespace|minecraft
]] becomes the namespace and the whole string becomes the path.
It is recommended to always include a :
in the string format of resource locations.
;Examples
{| class="wikitable"
|-
! String !! Resolved namespace !! Resolved path !! What the game converts it back to
|-
| bar:code
|| bar
|| code
|| bar:code
|-
| minecraft:zombie
|| minecraft
|| zombie
|| minecraft:zombie
|-
| diamond
|| minecraft
{{only|java}}
None{{only|bedrock}} || diamond
|| minecraft:diamond
{{only|java}}diamond
{{only|bedrock}}
|-
| :dirt
|| minecraft
|| dirt
|| minecraft:dirt
{{needs testing|bedrock=1}}
|-
| minecraft:
|| minecraft
|| None || minecraft:
{{needs testing|bedrock=1}}
|-
| :
|| minecraft
|| None || minecraft:
{{needs testing|bedrock=1}}
|-
| Empty String || minecraft
|| None || minecraft:
{{needs testing|bedrock=1}}
|-
| foo/bar:coal
|| Invalid character /
|| ||
|-
| minecraft/villager
|| minecraft
{{only|java}}
None{{only|bedrock}} || minecraft/villager
|| minecraft:minecraft/villager
{{only|java}}minecraft/villager
{{only|bedrock}}
|-
| mypack_recipe
|| minecraft
{{only|java}}
None{{only|bedrock}} || mypack_recipe
|| minecraft:mypack_recipe
{{only|java}}mypack_recipe
{{only|bedrock}}
|-
| mymap:schrödingers_var
|| mymap
|| Invalid character ö
{{only|java}}schrödingers_var
{{only|bedrock}} || mymap:schrödingers_var
{{only|bedrock}}
|-
| custom_pack:Capital
|| custom_pack
|| Invalid character C
{{only|java}}Capital
{{only|bedrock}} || custom_pack:Capital
{{only|bedrock}}
|}
== Usage ==
Here list all places that use resource locations:
===''Java Edition''===
{{IN|java}}, resource locations act mainly as main keys of objects in registries, or file paths of contents in packs. Besides, some customizable or hardcoded contents also use resource locations.
==== Registries and registry objects ====
Each registry and each object in registries has a resource location to represent it.
There's a root registry with resource location of {{cd|minecraft:root}}. Other registries are registered into the root registry as its entries.
The following is the list of registries and their resource locations:
; Root Registry:{{cd|minecraft:root}}
:* Attribute: {{cd|minecraft:attribute}}
:* Block: {{cd|minecraft:block}}
:* Block entity type: {{cd|minecraft:block_entity_type}}
:* Chunk status: {{cd|minecraft:chunk_status}}
:* Command argument type: {{cd|minecraft:command_argument_type}}
:* Dimension and Level stem: {{cd|minecraft:dimension}}
:* Dimension type: {{cd|minecraft:dimension_type}}
:* Enchantment: {{cd|minecraft:enchantment}}
:* Entity type: {{cd|minecraft:entity_type}}
:* Fluid: {{cd|minecraft:fluid}}
:* Game event: {{cd|minecraft:game_event}}
:* Position source type (used by game events): {{cd|minecraft:position_source_type}}
:* Item: {{cd|minecraft:item}}
:* Menu type: {{cd|minecraft:menu}}
:* Mob effect: {{cd|minecraft:mob_effect}}
:* Particle type: {{cd|minecraft:particle_type}}
:* Potion: {{cd|minecraft:potion}}
:* Recipe serializer: {{cd|minecraft:recipe_serializer}}
:* Recipe type: {{cd|minecraft:recipe_type}}
:* Sound event: {{cd|minecraft:sound_event}}
:* Statistics type: {{cd|minecraft:stat_type}}
:* Custom Statistics: {{cd|minecraft:custom_stat}}
:* Entity data registries
:** Entity schedule activity: {{cd|minecraft:activity}}
:** Entity memory module type: {{cd|minecraft:memory_module_type}}
:** Entity schedule: {{cd|minecraft:schedule}}
:** Entity AI sensor type: {{cd|minecraft:sensor_type}}
:** Painting motive: {{cd|minecraft:motive}}
:** Villager profession: {{cd|minecraft:villager_profession}}
:** Villager type: {{cd|minecraft:villager_type}}
:** Poi type: {{cd|minecraft:point_of_interest_type}}
:* Loot table serializer registries:
:** Loot condition type: {{cd|minecraft:loot_condition_type}}
:** Loot function type: {{cd|minecraft:loot_function_type}}
:** Loot nbt provider type: {{cd|minecraft:loot_nbt_provider_type}}
:** Loot number provider type: {{cd|minecraft:loot_number_provider_type}}
:** Loot pool entry type: {{cd|minecraft:loot_pool_entry_type}}
:** Loot score provider type: {{cd|minecraft:loot_score_provider_type}}
:* Json file value provider registries:
:** Float provider type: {{cd|minecraft:float_provider_type}}
:** Int provider type: {{cd|minecraft:int_provider_type}}
:** Height provider type: {{cd|minecraft:height_provider_type}}
:* World generator registries:
:** Block predicate type: {{cd|minecraft:block_predicate_type}}
:** Structure featrue rule test type: {{cd|minecraft:rule_test}}
:** Structure featrue position rule test type: {{cd|minecraft:pos_rule_test}}
:** World carver: {{cd|minecraft:worldgen/carver}}
:** Configured world carver: {{cd|minecraft:worldgen/configured_carver}}
:** Feature: {{cd|minecraft:worldgen/feature}}
:** Configured feature: {{cd|minecraft:worldgen/configured_feature}}
:** Structure set: {{cd|minecraft:worldgen/structure_set}}
:** Structure processor type: {{cd|minecraft:worldgen/structure_processor}}
:** Structure processor list: {{cd|minecraft:worldgen/processor_list}}
:** Structure pool element type: {{cd|minecraft:worldgen/structure_pool_element}}
:** Structure template pool: {{cd|minecraft:worldgen/template_pool}}
:** Structure piece type: {{cd|minecraft:worldgen/structure_piece}}
:** Structure feature: {{cd|minecraft:worldgen/structure_type}}
:** Configured structure feature: {{cd|minecraft:worldgen/structure}}
:** Structure placement type: {{cd|minecraft:worldgen/structure_placement}}
:** Placement modifier type: {{cd|minecraft:worldgen/placement_modifier_type}}
:** Placed feature: {{cd|minecraft:worldgen/placed_feature}}
:** Biome: {{cd|minecraft:worldgen/biome}}
:** Biome source: {{cd|minecraft:worldgen/biome_source}}
:** Normal noise: {{cd|minecraft:worldgen/noise}}
:** Noise generator settings: {{cd|minecraft:worldgen/noise_settings}}
:** Density function: {{cd|minecraft:worldgen/density_function}}
:** Density function type: {{cd|minecraft:worldgen/density_function_type}}
:** World preset: {{cd|minecraft:worldgen/world_preset}}
:** Flat world generator preset: {{cd|minecraft:worldgen/flat_level_generator_preset}}
:** Chunk generator: {{cd|minecraft:worldgen/chunk_generator}}
:** Surface condition source: {{cd|minecraft:worldgen/material_condition}}
:** Surface rule source: {{cd|minecraft:worldgen/material_rule}}
:** Block state provider type: {{cd|minecraft:worldgen/block_state_provider_type}}
:** Foliage placer type: {{cd|minecraft:worldgen/foliage_placer_type}}
:** Trunk placer type: {{cd|minecraft:worldgen/trunk_placer_type}}
:** Tree decorator type: {{cd|minecraft:worldgen/tree_decorator_type}}
:** Feature size type: {{cd|minecraft:worldgen/feature_size_type}}
====Pack contents====
Resource locations are also used to represent files' paths in data pack or resource pack.
; Data pack
:* Tags
:* Advancements
:* Recipes
:* Predicates
:* Loot tables
:* Item modifier
:* Functions
:* Structure files
:* Dimensions
:* Dimension types
:* ''World generator contents''
:** Biomes
:** Configured carvers
:** Configured features
:** Configured structure features
:** Placed features
:** Structures
:** Structure sets
:** Processor lists
:** Template pools
:** Noise
:** Noise generator settings
:** Density functions
:** Flat level generator presets
:** World presets
; Resource pack
:* Block states
:* Models
:* Textures
:* Sounds
:* Fonts
:* Font resource files
:* Particles
:* shaders
===== Locating contents in packs =====
Given objects from resource packs and data packs are files, the resource locations represent corresponding paths.
Though the locations vary by object type and the pack type the object type belongs to, there is a pattern to follow. In general, the location is in the fashion of pack_type/namespace/object_type/name.suffix, where all the / (forward slash) symbol (may be part of object_type or name) is replaced by operating system-dependent directory separator.
Given the type of content we want to locate, we can find out the corresponding {{cd|''pack_type''}}, {{cd|''object_type''}}, and {{cd|''suffix''}}. Then, we can substitute in and find out the final file location of the content.