ID de objeto
Los identificadores de objeto (también conocidos como líneas de nombre,[1] resource locations,[2] or resource identifiers[3]) son una forma de declarar e identificar los objetos incluidos en el juego y definidos por los usuarios al jugar a Minecraft, evitando ambigüedades generadas por sus nombres.
Sumario
Uso[editar | editar código]
Namespaced identifiers are used as plain string to reference blocks, items, entity types, recipes, functions, advancements, tags, and various other objects in vanilla Minecraft. Interestingly, block states are not namespaced.
A valid namespaced identifier has a format of namespace:name
, where only certain characters can be used.
This is a list of all places that have namespaced IDs:
- Built-in registries
-
- Attributes
- Bloques
- Block entities[Solo Edición Java]
- Fluids[Solo Edición Java]
- Objetos
- Entidades
- Mob memories[Solo Edición Java]
- Painting motives[Solo Edición Java]
- Villager professions[Solo Edición Java]
- Villager types[Solo Edición Java]
- Status effects
- Potion types[Solo Edición Java]
- Enchantments
- Partículas
- Dimensions[Solo Edición Java]
- Biomes
- Statistics[Solo Edición Java]
- Recipe types[Solo Edición Java]
- Recipe serializers[Solo Edición Java]
- Sound events
- Data pack contents[Solo Edición Java]
-
- Advancements
- Loot tables
- Funcions
- Structure files
- Recetas
- Block/Fluid/Item/Entity type/Function Tags
- Add on contents[Solo Edición Bedrock]
-
- Loot tables
- Funciones
- Resource pack contents[Solo Edición Java]
-
- Block state files
- Modelos
- Texturas
- Sonidos
- Other customizable contents[Solo Edición Java]
-
- Boss bars
- Command storage
- Other non-customizable (without mods) contents
-
- Loot functions
- Loot conditions
- Loot types
- Command argument types
Legal characters[editar | editar código]
Edición Java[editar | editar código]
The namespace and the name of an ID should only contain the following symbols:
0123456789
Numbersabcdefghijklmnopqrstuvwxyz
Lowercase letters_
Underscore-
Hyphen/minus.
Dot
The following characters are illegal in the namespace, but acceptable in the name:
/
Forward slash (directory separator)
The preferred naming convention for either namespace or name is snake_case
.
Edición Bedrock[editar | editar código]
The namespace and the name of an ID can contain all symbols with the exception of slashes and colons.
The following characters are illegal in the namespace, but acceptable in the name of loot tables and functions.
/
Forward slash (directory separator)
The preferred naming convention for either namespace or name is snake_case
.
Conversion to string[editar | editar código]
A namespaced ID would be converted to a string by appending its namespace with a :
(colon) and its name.
Ejemplos:
Namespace | Name | String representation |
---|---|---|
minecraft |
diamond |
minecraft:diamond
|
foo |
bar.baz |
foo:bar.baz
|
minecraftwiki |
commands/minecraft_wiki |
minecraftwiki:commands/minecraft_wiki
|
Conversion from string[editar | editar código]
Unlike that namespaced IDs can always be converted to strings, some strings cannot convert to namespaced IDs.
A few restrictions:
- The string can have at most one
:
(colon) character - The rest of the string must fulfill the requirement of legal characters
- If the
:
is present, the part of string before the:
(the namespace) must not contain/
or.
When the :
is present, the part of string before the :
becomes the namespace and that after the :
becomes the name.
When the :
is absent, minecraft
becomes the namespace and the whole string becomes the name.[Solo Edición Java]
It is recommended to always include a :
in the string format of namespaced IDs.
- Examples
String | Resolved namespace | Resolved name | What the game converts it back to |
---|---|---|---|
bar:code |
bar |
code |
bar:code
|
minecraft:zombie |
minecraft |
zombie |
minecraft:zombie
|
diamond |
minecraft [Solo Edición Java]None[Solo Edición Bedrock] |
diamond |
minecraft:diamond [Solo Edición Java]diamond [Solo Edición Bedrock]
|
foo/bar:coal |
Invalid character / |
||
minecraft/villager |
minecraft [Solo Edición Java]None[Solo Edición Bedrock] |
minecraft/villager |
minecraft:minecraft/villager [Solo Edición Java]minecraft/villager [Solo Edición Bedrock]
|
mypack_recipe |
minecraft [Solo Edición Java]None[Solo Edición Bedrock] |
mypack_recipe |
minecraft:mypack_recipe [Solo Edición Java]mypack_recipe [Solo Edición Bedrock]
|
mymap:schrödingers_var |
mymap |
Invalid character ö [Solo Edición Java]schrödingers_var [Solo Edición Bedrock] |
mymap:schrödingers_var [Solo Edición Bedrock]
|
custom_pack:Capital |
custom_pack |
Invalid character C [Solo Edición Java]Capital [Solo Edición Bedrock] |
custom_pack:Capital [Solo Edición Bedrock]
|
Locating contents in packs[editar | editar código]
Given objects from resource packs and data packs are files, the namespaced ID can also be used to find corresponding files that declared objects of the ID.
Though the locations varies by object type and the pack type the object type belongs to, there is a pattern to follow. In general, The location is in a 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.
Mappings from object type to pack_type
, object_type
, and suffix
variables
Object Type | Object's pack | pack_type substitution |
object_type substitution |
suffix substitution
|
---|---|---|---|---|
Block States | Resource pack | assets |
blockstates |
json
|
Models | Resource pack | assets |
models |
json
|
Particles | Resource pack | assets |
particles |
json
|
Textures | Resource pack | assets |
textures |
png
|
Advancements | Data pack | data |
advancements |
json
|
Functions | Data pack | data |
functions |
mcfunction
|
Loot tables | Data pack | data |
loot_tables |
json
|
Recipes | Data pack | data |
recipes |
json
|
Structures | Data pack | data |
structures |
nbt
|
Block tags | Data pack | data |
tags/blocks |
json
|
Entity type tags | Data pack | data |
tags/entity_types |
json
|
Item tags | Data pack | data |
tags/items |
json
|
Fluid tags | Data pack | data |
tags/fluids |
json
|
Function tags | Data pack | data |
tags/functions |
json
|
Note: Certain elements in the resource pack is not necessarily backed by an object with namespace ID, such as GUI textures.
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
Namespaced ID | 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
|
Namespaces[editar | editar código]
![]() |
“ |
|
„ |
— Dinnerbone en namespaces[4] |
A namespace is a domain for contents. It is to prevent potential content conflicts or unintentional overrides of object of a 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[editar | editar código]
Minecraft reserves the minecraft
namespace; when a namespace is not specified, a namespaced ID falls back to minecraft
[Solo Edición Java]. 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[editar | editar código]
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, the namespace should be as particular 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, butplayer_name_battle_royale
would be much better.
In either case, these poorly chosen namespaces reduces the exposure of a project and brings difficulties for debugging when there is multiple content creations applied to the game.
Other built-in namespaces[editar | editar código]
The default resource pack of Minecraft declares Realms-oriented language files in the realms
namespace (located at assets/realms/lang/<language-code>.json
) and game-related language files in the minecraft
namespace, even though translation keys are not namespaced IDs. 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.[5]
History[editar | editar código]
Edición Java | |||||
---|---|---|---|---|---|
1.6.1 | 13w21a | Added namespaced IDs alongside the minecraft prefix for identifying assets. | |||
1.7.2 | 13w37a | Commands now accept name IDs aside from numerical IDs. | |||
1.11 | 16w32a | Namespaced IDs now have a character restriction. | |||
Disallowed uppercase characters in namespaced IDs. | |||||
1.13 | 17w47a | After the flattening, namespaced IDs are the only accepted form of ID. | |||
pre4 | Namespaced IDs are now used to identify plugin message channels.[6] | ||||
1.14.4 | pre1 | The realms namespace is added to the client jar's builtin resource pack. | |||
1.16 | 20w14a | Attributes are now namespaced IDs. | |||
Edición Pocket Alpha | |||||
0.16.0 | build 1 | Added commands, which supported string IDs. However, these IDs were not namespaced yet. | |||
Edición Bedrock | |||||
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[editar | editar código]
Referencias[editar | editar código]
- ↑ DataFixerUpper/NamespacedStringType.java at 8b5f82ab78b30ff5813b3a7f3906cd3f4f732acf · Mojang/DataFixerUpper – GitHub
- ↑ Minecraft Java Edition 1.13 changes – GitHub Gist
- ↑ "Minecraft Snapshot 19w39a" – Minecraft.net, September 27, 2019
- ↑ "Minecraft Snapshot 17w43a" – Minecraft.net
- ↑ Minecraft Java Edition 1.13 changes – GitHub Gist
- ↑ Protocol History – wiki.vg
Enlaces externos[editar | editar código]
- Namespaces, as explained in "Minecraft Snapshot 17w43a" – Minecraft.net.
Ediciones |
| ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Desarrollo |
| ||||||||||
Técnico | |||||||||||
Multijugador | |||||||||||
Características exclusivas |
| ||||||||||
Removido |