Identifier

From Minecraft Wiki
(Redirected from Resource location)
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.

[edit | edit source]

Java Edition

[edit | edit source]

The namespace and the path of a 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.

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

  • File directory.png: Sprite image for directory in Minecraft minecraft:root: Root registry.
    • File file.png: Sprite image for file in Minecraft minecraft:attribute: Attributes.
    • File file.png: Sprite image for file in Minecraft minecraft:block: Blocks.
    • File file.png: Sprite image for file in Minecraft minecraft:block_entity_type: Block entity types.
    • File file.png: Sprite image for file in Minecraft minecraft:chunk_status: Chunk status.
    • File file.png: Sprite image for file in Minecraft minecraft:command_argument_type: Command argument types.
    • File file.png: Sprite image for file in Minecraft minecraft:dimension*: Dimensions and level stems.
    • File file.png: Sprite image for file in Minecraft minecraft:dimension_type*: Dimension types.
    • File file.png: Sprite image for file in Minecraft minecraft:enchantment*: Enchantments.
    • File file.png: Sprite image for file in Minecraft minecraft:entity_type: Entity types.
    • File file.png: Sprite image for file in Minecraft minecraft:fluid: Fluids.
    • File file.png: Sprite image for file in Minecraft minecraft:game_event: Game events.
    • File file.png: Sprite image for file in Minecraft minecraft:position_source_type: Position source types (used by game events).
    • File file.png: Sprite image for file in Minecraft minecraft:item: Items.
    • File file.png: Sprite image for file in Minecraft minecraft:menu*: Menu types.
    • File file.png: Sprite image for file in Minecraft minecraft:mob_effect: Mob effects.
    • File file.png: Sprite image for file in Minecraft minecraft:particle_type: Particle types.
    • File file.png: Sprite image for file in Minecraft minecraft:potion: Potions.
    • File file.png: Sprite image for file in Minecraft minecraft:recipe_serializer: Recipe serializers.
    • File file.png: Sprite image for file in Minecraft minecraft:recipe_type: Recipe types.
    • File file.png: Sprite image for file in Minecraft minecraft:sound_event: Sound events.
    • File file.png: Sprite image for file in Minecraft minecraft:stat_type: Statistics types.
    • File file.png: Sprite image for file in Minecraft minecraft:custom_stat: Custom Statistics.
    • File file.png: Sprite image for file in Minecraft minecraft:world_clock[upcoming JE 26.1]: World clocks.
    • File file.png: Sprite image for file in Minecraft minecraft:timeline Timelines for world clocks.
    • File directory.png: Sprite image for directory in Minecraft Entity data registries:
      • File file.png: Sprite image for file in Minecraft minecraft:activity: Entity schedule activitys.
      • File file.png: Sprite image for file in Minecraft minecraft:memory_module_type: Entity memory module types.
      • File file.png: Sprite image for file in Minecraft minecraft:schedule: Entity schedules.
      • File file.png: Sprite image for file in Minecraft minecraft:sensor_type: Entity AI sensor types.
      • File file.png: Sprite image for file in Minecraft minecraft:motive*: Painting motives.
      • File file.png: Sprite image for file in Minecraft minecraft:villager_profession: Villager professions.
      • File file.png: Sprite image for file in Minecraft minecraft:villager_type: Villager types.
      • File file.png: Sprite image for file in Minecraft minecraft:villager_trade[upcoming JE 26.1]: Villager trade definition.
      • File file.png: Sprite image for file in Minecraft minecraft:point_of_interest_type: Poi types.
    • File directory.png: Sprite image for directory in Minecraft Loot table serializers:
      • File file.png: Sprite image for file in Minecraft minecraft:loot_condition_type: Loot condition types.
      • File file.png: Sprite image for file in Minecraft minecraft:loot_function_type: Loot function types.
      • File file.png: Sprite image for file in Minecraft minecraft:loot_nbt_provider_type: Loot nbt provider types.
      • File file.png: Sprite image for file in Minecraft minecraft:loot_number_provider_type: Loot number provider types.
      • File file.png: Sprite image for file in Minecraft minecraft:loot_pool_entry_type: Loot pool entry types.
      • File file.png: Sprite image for file in Minecraft minecraft:loot_score_provider_type: Loot score provider types.
    • File directory.png: Sprite image for directory in Minecraft JSON file value providers:
      • File file.png: Sprite image for file in Minecraft minecraft:float_provider_type: Float provider types.
      • File file.png: Sprite image for file in Minecraft minecraft:int_provider_type: Int provider types.
      • File file.png: Sprite image for file in Minecraft minecraft:height_provider_type: Height provider types.
    • File directory.png: Sprite image for directory in Minecraft World generator registries:
      • File file.png: Sprite image for file in Minecraft minecraft:block_predicate_type: Block predicate types.
      • File file.png: Sprite image for file in Minecraft minecraft:rule_test: Structure feature rule test types.
      • File file.png: Sprite image for file in Minecraft minecraft:pos_rule_test: Structure feature position rule test types.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/carver: World carvers.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/configured_carver*: Configured world carvers.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/feature: Features.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/configured_feature*: Configured features.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/structure_set: Structure sets.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/structure_processor: Structure processor types.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/processor_list*: Structure processor lists.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/structure_pool_element: Structure pool element types.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/template_pool*: Structure template pools.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/structure_piece: Structure piece types.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/structure_type: Structure features.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/structure*: Configured structure features.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/structure_placement: Structure placement types.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/placement_modifier_type: Placement modifier types.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/placed_feature*: Placed features.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/biome*: Biomes.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/biome_source: Biome sources.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/noise*: Normal noise.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/noise_settings*: Noise generator settings.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/density_function: Density functions.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/density_function_type: Density function types.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/world_preset: World presets.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/flat_level_generator_preset: Flat world generator presets.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/chunk_generator: Chunk generators.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/material_condition: Surface condition sources.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/material_rule: Surface rule sources.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/block_state_provider_type: Block state provider types.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/foliage_placer_type: Foliage placer types.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/trunk_placer_type: Trunk placer types.
      • File file.png: Sprite image for file in Minecraft minecraft:worldgen/tree_decorator_type: Tree decorator types.
      • File file.png: Sprite image for file in Minecraft 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.

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.

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, 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_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.[5]
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.

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]
[edit | edit source]
[edit | edit source]