VOOZH about

URL: https://minecraft.wiki/w/Namespaced_ID

⇱ Identifier – Minecraft Wiki


Identifier

From Minecraft Wiki
(Redirected from Namespaced ID)
Jump to navigation Jump to search

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 an identifier 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.

.. is not a valid namespace.

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]
This section is a work in progress.
 
Please help expand and improve it. The talk page may contain suggestions.

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]
This section needs to be updated.
 
Please update this section to reflect recent updates or newly available information. The talk page may contain suggestions.
Reason: Lots of tags seem missing, see zh:注册表 for reference to add here if you speak Chinese

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 (*).

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 something and a mod (or map, or whatever) adds something, they're both different somethings. 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 to minecraft. This means that something and minecraft:something are the same thing.

Dinnerbone on namespaces[4]

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, an 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_royale would not be informative to look up as well, but player_name_battle_royale would 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.113w21aAdded resource locations alongside the minecraft prefix for identifying assets.
1.7.213w37aCommands now accept name IDs aside from numerical IDs.
1.814w02aItem 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.1116w32aResource locations now have a character restriction.
Disallowed uppercase characters in resource locations.
1.1317w47aAfter the flattening, resource locations are the only accepted form of identifiers.
pre4Resource locations are now used to identify plugin message channels.
1.14.4pre1The realms namespace is added to the client jar's builtin resource pack.
1.1620w14aAttributes are now resource locations.
1.21.1125w45aResourceLocation is renamed to Identifier in the game's code.
26.1snap6.. is no longer a valid namespace.

Bedrock Edition

[edit | edit source]
Pocket Edition Alpha
v0.16.0build 1Added commands, which supported string IDs. However, these identifiers were not namespaced yet.
build 4All entity attributes are now namespaced.
Bedrock Edition
1.6.0beta 1.6.0.5In the save files for worlds, items now use namespaced IDs instead of numeric IDs.
1.12.0beta 1.12.0.2IDs 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]

External links

[edit | edit source]

Navigation

[edit | edit source]
Retrieved from "https://minecraft.wiki/w/Identifier?oldid=3652263"

Navigation menu