Identifier
Identifiers (also known as resource locations, namespaced IDs, namespaced identifiers, resource identifiers,[1] or namespaced strings[2]) 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
[edit | edit source]Identifiers are used as plain strings to reference blocks, items, entity types, and various other objects in vanilla Minecraft.
A valid identifier has a format of namespace:path, where only certain characters can be used.
Legal characters
[edit | edit source]Java Edition
[edit | edit source]The namespace and the path of a identifier should only contain the following symbols:
0123456789NumbersabcdefghijklmnopqrstuvwxyzLowercase 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
[edit | edit source]The namespace and the path of a 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
[edit | edit source]An identifier is converted to a string by concatenating its namespace with a : (colon) and its path.
Examples:
| 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
[edit | edit source]All identifiers can be converted to strings; however, not all strings can be converted to identifiers.
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. 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 Edition, and in some cases in Bedrock Edition, when the : is absent, minecraft becomes the namespace and the whole string becomes the path.
It is recommended to always include a : in the string format of identifiers.
- Examples
| 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
|
|
diamond
|
|
:dirt |
minecraft |
dirt |
minecraft:dirt[needs testing in Bedrock Edition]
|
minecraft: |
minecraft |
None | minecraft:[needs testing in Bedrock Edition]
|
: |
minecraft |
None | minecraft:[needs testing in Bedrock Edition]
|
| Empty String | minecraft |
None | minecraft:[needs testing in Bedrock Edition]
|
foo/bar:coal |
Invalid character / |
||
minecraft/villager
|
|
minecraft/villager
|
|
mymap:schrödingers_var |
mymap
|
|
mymap:schrödingers_var[Bedrock Edition only]
|
custom_pack:Capital |
custom_pack
|
|
custom_pack:Capital[Bedrock Edition only]
|
Java Edition usage
[edit | edit source]In Java Edition, identifiers act mainly as main keys of objects in registries or file paths of contents in data packs and resource packs. Some non-customizable contents also use identifiers to identify them.
Registries and registry objects
[edit | edit source]All registries and objects therein have identifiers to represent them. At the root of all registries is a registry with the identifier of minecraft:root into which all other registries are registered. Most registries are intended only for use internally by the game and by extension by mods, but some dynamic registries can have content added to them through data packs, marked in the list below with an asterisk (*).
minecraft:root: Root registry.
minecraft:attribute: Attributes.
minecraft:block: Blocks.
minecraft:block_entity_type: Block entity types.
minecraft:chunk_status: Chunk status.
minecraft:command_argument_type: Command argument types.
minecraft:dimension*: Dimensions and level stems.
minecraft:dimension_type*: Dimension types.
minecraft:enchantment*: Enchantments.
minecraft:entity_type: Entity types.
minecraft:fluid: Fluids.
minecraft:game_event: Game events.
minecraft:position_source_type: Position source types (used by game events).
minecraft:item: Items.
minecraft:menu*: Menu types.
minecraft:mob_effect: Mob effects.
minecraft:particle_type: Particle types.
minecraft:potion: Potions.
minecraft:recipe_serializer: Recipe serializers.
minecraft:recipe_type: Recipe types.
minecraft:sound_event: Sound events.
minecraft:stat_type: Statistics types.
minecraft:custom_stat: Custom Statistics.
minecraft:world_clock[upcoming JE 26.1]: World clocks.
minecraft:timelineTimelines for world clocks.
Entity data registries:
minecraft:activity: Entity schedule activitys.
minecraft:memory_module_type: Entity memory module types.
minecraft:schedule: Entity schedules.
minecraft:sensor_type: Entity AI sensor types.
minecraft:motive*: Painting motives.
minecraft:villager_profession: Villager professions.
minecraft:villager_type: Villager types.
minecraft:villager_trade[upcoming JE 26.1]: Villager trade definition.
minecraft:point_of_interest_type: Poi types.
Loot table serializers:
minecraft:loot_condition_type: Loot condition types.
minecraft:loot_function_type: Loot function types.
minecraft:loot_nbt_provider_type: Loot nbt provider types.
minecraft:loot_number_provider_type: Loot number provider types.
minecraft:loot_pool_entry_type: Loot pool entry types.
minecraft:loot_score_provider_type: Loot score provider types.
JSON file value providers:
minecraft:float_provider_type: Float provider types.
minecraft:int_provider_type: Int provider types.
minecraft:height_provider_type: Height provider types.
World generator registries:
minecraft:block_predicate_type: Block predicate types.
minecraft:rule_test: Structure feature rule test types.
minecraft:pos_rule_test: Structure feature position rule test types.
minecraft:worldgen/carver: World carvers.
minecraft:worldgen/configured_carver*: Configured world carvers.
minecraft:worldgen/feature: Features.
minecraft:worldgen/configured_feature*: Configured features.
minecraft:worldgen/structure_set: Structure sets.
minecraft:worldgen/structure_processor: Structure processor types.
minecraft:worldgen/processor_list*: Structure processor lists.
minecraft:worldgen/structure_pool_element: Structure pool element types.
minecraft:worldgen/template_pool*: Structure template pools.
minecraft:worldgen/structure_piece: Structure piece types.
minecraft:worldgen/structure_type: Structure features.
minecraft:worldgen/structure*: Configured structure features.
minecraft:worldgen/structure_placement: Structure placement types.
minecraft:worldgen/placement_modifier_type: Placement modifier types.
minecraft:worldgen/placed_feature*: Placed features.
minecraft:worldgen/biome*: Biomes.
minecraft:worldgen/biome_source: Biome sources.
minecraft:worldgen/noise*: Normal noise.
minecraft:worldgen/noise_settings*: Noise generator settings.
minecraft:worldgen/density_function: Density functions.
minecraft:worldgen/density_function_type: Density function types.
minecraft:worldgen/world_preset: World presets.
minecraft:worldgen/flat_level_generator_preset: Flat world generator presets.
minecraft:worldgen/chunk_generator: Chunk generators.
minecraft:worldgen/material_condition: Surface condition sources.
minecraft:worldgen/material_rule: Surface rule sources.
minecraft:worldgen/block_state_provider_type: Block state provider types.
minecraft:worldgen/foliage_placer_type: Foliage placer types.
minecraft:worldgen/trunk_placer_type: Trunk placer types.
minecraft:worldgen/tree_decorator_type: Tree decorator types.
minecraft:worldgen/feature_size_type: Feature size types.
Pack contents
[edit | edit source]Identifiers are also used to represent file paths in data packs or resource packs.
- 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 state model definitions
- Models
- Textures
- Sounds
- Fonts
- Font resource files
- Particles
- Shaders
Locating contents in packs
[edit | edit source]Given that objects in resource packs and data packs are files, the identifiers are constructed from their path relative to the data or assets folder.
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 pack_type, object_type, and suffix. Then, we can substitute in and find out the final file location of the content.
Examples
| Identifier | Content Type | pack_type |
object_type |
suffix |
Final Location |
|---|---|---|---|---|---|
my_texture_pack:diamonds |
Texture | assets |
textures |
png |
assets/my_texture_pack/textures/diamonds.png
|
abc:run_game |
Function | data |
functions |
mcfunction |
data/abc/functions/run_game.mcfunction
|
block/torch(same as minecraft:block/torch) |
Model | assets |
models |
json |
assets/minecraft/models/block/torch.json
|
load(same as minecraft:load) |
Function Tag | data |
tags/functions |
json |
data/minecraft/tags/functions/load.json
|
rocket_pack:industry/start_of_story |
Advancement | data |
advancements |
json |
data/rocket_pack/advancements/industry/start_of_story.json
|
Registered pack contents
[edit | edit source]A registried pack content refers to pack content that is registered into a registry when the pack is loaded. For a registried pack content, its identifier works as both main key of registry entry and path of its resource file.
List of registered pack contents
| Content Type | Registered into | Folder | Suffix |
|---|---|---|---|
| Dimensions | minecraft:dimension |
data/namespace/dimension |
json
|
| Dimension types | minecraft:dimension_type |
data/namespace/dimension_type |
json
|
| Configured carvers | minecraft:worldgen/configured_carver |
data/namespace/worldgen/configured_carver |
json
|
| Configured features | minecraft:worldgen/configured_feature |
data/namespace/worldgen/configured_feature |
json
|
| Configured structure features | minecraft:worldgen/structure |
data/namespace/worldgen/structure |
json
|
| Structure sets | minecraft:worldgen/structure_set |
data/namespace/worldgen/structure_set |
json
|
| Processor lists | minecraft:worldgen/processor_list |
data/namespace/worldgen/processor_list |
json
|
| Template pools | minecraft:worldgen/template_pool |
data/namespace/worldgen/template_pool |
json
|
| Placed features | minecraft:worldgen/placed_feature |
data/namespace/worldgen/placed_feature |
json
|
| Biomes | minecraft:worldgen/biome |
data/namespace/worldgen/biome |
json
|
| Noise | minecraft:worldgen/noise |
data/namespace/worldgen/noise |
json
|
| Noise generator settings | minecraft:worldgen/noise_settings |
data/namespace/worldgen/noise_settings |
json
|
| Density functions | minecraft:worldgen/density_function |
data/namespace/worldgen/density_function |
json
|
| Flat level generator presets | minecraft:worldgen/flat_level_generator_preset |
data/namespace/worldgen/flat_level_generator_preset |
json
|
| World presets | minecraft:worldgen/world_preset |
data/namespace/worldgen/world_preset |
json
|
Other contents
[edit | edit source]- Customizable contents
-
- Boss bars
- Command storages
- Hardcoded contents
-
- Cat types for predicates (e.g. textures/entity/cat/tabby.png, textures/entity/cat/jellie.png)
- Criteria triggers
- Item properties (i.e. item predicates in models. e.g. angle, custom_model_data)
- Loot context param sets (i.e. types of loot table. e.g. barter, generic)
- Unaccessible contents:
- Suggestion providers for autocompletion of commands (e.g. summonable_entities, all_recipes)
- Entity models
- Loot context params (e.g. this_entity, origin, tool)
Bedrock Edition usage
[edit | edit source]Unlike Java Edition, where there is a unified standard and handling methods of them, namespaced identifiers are usually treated as normal strings in Bedrock Edition. Moreover, some objects are identified based on their path (e.g. the identifier for recipes and trades) rather than what was defined in their file. In these cases, it is recommended that a folder named after the namespace is parented before the file at hand.[3]
The following is a list of all places that use namespaced identifiers:
Built-in contents
[edit | edit source]- Blocks
- Block traits
- Block entities
- Items
- Entities
- Status effects
- Dimensions
- Biomes
- Structures
- Features
- Entity attributes
- Item NBT components
- Item components
- Block components
- Entity components
- JSON schemas
- GameTest script-enabled components
Registried add-on entries
[edit | edit source]A registried add-on entry refers to any add-on content that is registered with an identifier declared within the content's file definition. Custom content under these types are able to be created.
Here is a list of registried add-on entries whose identifiers are namespaced.
- Behavior pack contents
-
- Blocks
- Block states
- Entities
- Entity events
- Items
- Spawn rules
- Biomes
- Features
- Feature rules
- Recipes
- Structures
- GameTests
- Dialog scenes
- Spawn groups
- Structure sets
- Template pools
- Processor lists
- Catalog groups
- Resource pack contents
-
- Attachables
- Cameras
- Entity client definitions
- Particle effects
- Biome client definitions
- Fog settings
- Lighting settings
- Atmosphere settings
- Color grading settings
- Water effect settings
Some custom fields in add-on files can also be namespaced, such as custom block properties and entity component groups, which aren't listed here.
Others
[edit | edit source]- Structures saved from a structure block
Script-registered entries
[edit | edit source]Some content may also be registered within the scripts of behavior packs. These are read as the world is generating.
- Block components
- Item components
- Commands
Namespaces
[edit | edit source]
This isn't a new concept, but I thought I should reiterate what a "namespace" is. Most things in the game has a namespace, so that if we add
somethingand a mod (or map, or whatever) addssomething, they're both differentsomethings. Whenever you're asked to name something, for example a loot table, you're expected to also provide what namespace that thing comes from. If you don't specify the namespace, we default tominecraft. This means thatsomethingandminecraft:somethingare the same thing.
A namespace is a domain for content. It is to prevent potential content conflicts or unintentional overrides of objects of the same name.
For example, two data packs add two minigame mechanisms to Minecraft; both have a function named start. Without namespaces, these two functions would clash and the minigames would be broken. When they have different namespaces of minigame_one and minigame_two, the functions would become minigame_one:start and minigame_two:start, which no longer conflict.
minecraft namespace
[edit | edit source]Minecraft reserves the minecraft namespace. When a namespace is not specified, a identifier falls back to minecraft[Java Edition only]. As a result, the minecraft namespace should only be used by content creators when the content needs to overwrite or modify existing Minecraft data, such as adding a function to the minecraft:load function tag.
Custom namespace
[edit | edit source]The namespace should be distinct for different projects or content creations (e.g. a data pack, a resource pack, a mod, backing data/resource packs for a custom map, etc.)
To prevent potential clashes, it is recommended that the namespace should be as specific as possible:
- Avoid alphabet soups. For example, a project named "nuclear craft" should not use the namespace
nc, as this is too ambiguous. - Avoid words that are too vague.
battle_royalewould not be informative to look up as well, butplayer_name_battle_royalewould be much better. - For add-ons, use a shortened creator name followed by the name of the project in a format like
creatorname_packname.[3]
In either case, these poorly chosen namespaces reduce the exposure of a project and bring difficulties for debugging when there are multiple content creations applied to the game.
Other built-in namespaces
[edit | edit source]In Java Edition, the vanilla Minecraft resource pack declares Realms-oriented language files in the realms namespace (located at assets/realms/lang/.json) and game-related language files in the minecraft namespace, even though translation keys are not identifiers. The realms jar itself also declares its en_us.json language file and its various textures in the realms namespace.
In the IDs of command argument types, a brigadier namespace also appears for command argument types that are native to Brigadier.
In Bedrock Edition, the internal resource and behavior packs for Bedrock Editor contain some entities and items namespaced with editor.
History
[edit | edit source]Java Edition
[edit | edit source]| Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 1.6.1 | 13w21a | Added resource locations alongside the minecraft prefix for identifying assets. | |||||
| 1.7.2 | 13w37a | Commands now accept name IDs aside from numerical IDs. | |||||
| 1.8 | 14w02a | Item ID format has changed from using numbers (for example, TNT's id was 46) to namespaced IDs of the form minecraft:item_name. (Example: minecraft:tnt) | |||||
| 1.11 | 16w32a | Resource locations now have a character restriction. | |||||
| Disallowed uppercase characters in resource locations. | |||||||
| 1.13 | 17w47a | After the flattening, resource locations are the only accepted form of identifiers. | |||||
| pre4 | Resource locations are now used to identify plugin message channels.[5] | ||||||
| 1.14.4 | pre1 | The realms namespace is added to the client jar's builtin resource pack. | |||||
| 1.16 | 20w14a | Attributes are now resource locations. | |||||
| 1.21.11 | 25w45a | ResourceLocation is renamed to Identifier in the game's code. | |||||
Bedrock Edition
[edit | edit source]| Pocket Edition Alpha | |||||||
|---|---|---|---|---|---|---|---|
| v0.16.0 | build 1 | Added commands, which supported string IDs. However, these identifiers were not namespaced yet. | |||||
| build 4 | All entity attributes are now namespaced. | ||||||
| Bedrock Edition | |||||||
| 1.6.0 | beta 1.6.0.5 | In the save files for worlds, items now use namespaced IDs instead of numeric IDs. | |||||
| 1.12.0 | beta 1.12.0.2 | IDs are now namespaced using the minecraft prefix, to support custom items being added through add-ons. | |||||
See also
[edit | edit source]References
[edit | edit source]- ↑ "Minecraft Snapshot 19w39a" – Minecraft.net, September 27, 2019.
- ↑ DataFixerUpper/NamespacedStringType.java at 8b5f82ab78b30ff5813b3a7f3906cd3f4f732acf · Mojang/DataFixerUpper – GitHub
- ↑ a b "Guidelines for Building Cooperative Add-Ons" – Minecraft: Bedrock Edition Creator Documentation.
- ↑ "Minecraft Snapshot 17w43a" – Minecraft.net.
- ↑ Protocol History – wiki.vg
External links
[edit | edit source]- Namespaces, as explained in "Minecraft Snapshot 17w43a" – Minecraft.net..
Navigation
[edit | edit source]| Editions |
| ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Development |
| ||||||||
| Technical |
| ||||||||
| Multiplayer | |||||||||
| Exclusive features |
| ||||||||
| Removed | |||||||||