Nivel de permiso requerido |
2 |
---|---|
Restricciones |
Ninguno |
El comando /data
command permite al usuario obtener, fusionar, modificar y eliminar datos NBT de una entidad de bloque, entidad o almacenamiento NBT de comando.
Sintaxis[]
Hay cuatro instrucciones para /data
(get
, merge
, modify
, remove
), y los destinos/fuentes a los que hace referencia cada comando de instrucción pueden ser:
block <targetPos>
,entity <target>
, ostorage <target>
.
/data ...
... Plantilla:Ancla de texto
... (block <targetPos>|entity <target>|storage <target>) [<path>] [<scale>]
- Lea los datos NBT completos o la subsección de los datos NBT desde la entidad o posición del bloque objetivo al ejecutor con resaltado de sintaxis, escalado por <escala> si se especifica.
... Plantilla:Ancla de texto
... (block <targetPos>|entity <target>|storage <target>) <nbt>
- Fusionar los datos NBT de la posición o entidad del bloque de destino con los datos
<nbt>
especificados.
- Fusionar los datos NBT de la posición o entidad del bloque de destino con los datos
... Plantilla:Ancla de texto (block <targetPos>|entity <target>|storage <target>) <targetPath> ...
... append from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]
... append string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]
... append value <value>
- Agregue los datos de origen o los datos de valor directo al final de la lista apuntada.
... insert <index> from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]
... insert <index> string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]
... insert <index> value <value>
- Inserte los datos de origen o los datos de valor directo en la lista apuntada como elemento
<index>
, luego mueva los elementos superiores una posición hacia arriba.
- Inserte los datos de origen o los datos de valor directo en la lista apuntada como elemento
... merge from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]
... merge string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]
... merge value <value>
- Fusionar los datos de origen o los datos de valor directo en el objeto señalado.
... prepend from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]
... prepend string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]
... prepend value <value>
- Anteponga los datos de origen o los datos de valor directo al principio de la lista apuntada.
... set from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]
... set string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]
... set value <value>
- Establece la etiqueta especificada por
<targetPath>
a los datos de origen o datos de valor directo.
- Establece la etiqueta especificada por
... Plantilla:Ancla de texto
... (block <targetPos>|entity <target>|storage <target>) <path>
- Elimina los datos NBT en
<path>
de la posición o entidad del bloque objetivo. Los datos NBT del jugador no se pueden eliminar.
- Elimina los datos NBT en
Syntax displayed in various ways
Árbol simplificado: /data
- donde los argumentos sustituidos son:
<TARGET>
=(block <targetPos> | entity <target> | storage <target>)
<MODIFICATION>
=(append|insert <index>|merge|prepend|set)
<SOURCE>
=(block <sourcePos> | entity <source> | storage <source>)
Árbol aplastado: /data
… get (block <targetPos>|entity <target>|storage <target>) [<path>] [<scale>]
… merge (block <targetPos>|entity <target>|storage <target>) <nbt>
… modify (block <targetPos>|entity <target>|storage <target>) <targetPath> (append|insert <index>|merge|prepend|set)
… from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]
… string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]
… value <value>
… remove (block <targetPos>|entity <target>|storage <target>) <path>
Maximizado: data get block <targetPos> [<path>] [<scale>]
data get entity <target> [<path>] [<scale>]
data get storage <target> [<path>] [<scale>]
data merge block <targetPos> <nbt>
data merge entity <target> <nbt>
data merge storage <target> <nbt>
data modify block <targetPos> <targetPath> append from block <sourcePos> <sourcePath>
data modify block <targetPos> <targetPath> append from entity <source> <sourcePath>
data modify block <targetPos> <targetPath> append from storage <source> <sourcePath>
data modify block <targetPos> <targetPath> append string block <sourcePos> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> append string entity <source> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> append string storage <source> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> append value <value>
data modify block <targetPos> <targetPath> insert <index> from block <sourcePos> <sourcePath>
data modify block <targetPos> <targetPath> insert <index> from entity <source> <sourcePath>
data modify block <targetPos> <targetPath> insert <index> from storage <source> <sourcePath>
data modify block <targetPos> <targetPath> insert <index> string block <sourcePos> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> insert <index> string entity <source> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> insert <index> string storage <source> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> insert <index> value <value>
data modify block <targetPos> <targetPath> merge from block <sourcePos> <sourcePath>
data modify block <targetPos> <targetPath> merge from entity <source> <sourcePath>
data modify block <targetPos> <targetPath> merge from storage <source> <sourcePath>
data modify block <targetPos> <targetPath> merge string block <sourcePos> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> merge string entity <source> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> merge string storage <source> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> merge value <value>
data modify block <targetPos> <targetPath> prepend from block <sourcePos> <sourcePath>
data modify block <targetPos> <targetPath> prepend from entity <source> <sourcePath>
data modify block <targetPos> <targetPath> prepend from storage <source> <sourcePath>
data modify block <targetPos> <targetPath> prepend string block <sourcePos> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> prepend string entity <source> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> prepend string storage <source> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> prepend value <value>
data modify block <targetPos> <targetPath> set from block <sourcePos> <sourcePath>
data modify block <targetPos> <targetPath> set from entity <source> <sourcePath>
data modify block <targetPos> <targetPath> set from storage <source> <sourcePath>
data modify block <targetPos> <targetPath> set string block <sourcePos> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> set string entity <source> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> set string storage <source> <sourcePath> <start> <end>
data modify block <targetPos> <targetPath> set value <value>
data modify entity <target> <targetPath> append from block <sourcePos> <sourcePath>
data modify entity <target> <targetPath> append from entity <source> <sourcePath>
data modify entity <target> <targetPath> append from storage <source> <sourcePath>
data modify entity <target> <targetPath> append string block <sourcePos> <sourcePath> <start> <end>
data modify entity <target> <targetPath> append string entity <source> <sourcePath> <start> <end>
data modify entity <target> <targetPath> append string storage <source> <sourcePath> <start> <end>
data modify entity <target> <targetPath> append value <value>
data modify entity <target> <targetPath> insert <index> from block <sourcePos> <sourcePath>
data modify entity <target> <targetPath> insert <index> from entity <source> <sourcePath>
data modify entity <target> <targetPath> insert <index> from storage <source> <sourcePath>
data modify entity <target> <targetPath> insert <index> string block <sourcePos> <sourcePath> <start> <end>
data modify entity <target> <targetPath> insert <index> string entity <source> <sourcePath> <start> <end>
data modify entity <target> <targetPath> insert <index> string storage <source> <sourcePath> <start> <end>
data modify entity <target> <targetPath> insert <index> value <value>
data modify entity <target> <targetPath> merge from block <sourcePos> <sourcePath>
data modify entity <target> <targetPath> merge from entity <source> <sourcePath>
data modify entity <target> <targetPath> merge from storage <source> <sourcePath>
data modify entity <target> <targetPath> merge string block <sourcePos> <sourcePath> <start> <end>
data modify entity <target> <targetPath> merge string entity <source> <sourcePath> <start> <end>
data modify entity <target> <targetPath> merge string storage <source> <sourcePath> <start> <end>
data modify entity <target> <targetPath> merge value <value>
data modify entity <target> <targetPath> prepend from block <sourcePos> <sourcePath>
data modify entity <target> <targetPath> prepend from entity <source> <sourcePath>
data modify entity <target> <targetPath> prepend from storage <source> <sourcePath>
data modify entity <target> <targetPath> prepend string block <sourcePos> <sourcePath> <start> <end>
data modify entity <target> <targetPath> prepend string entity <source> <sourcePath> <start> <end>
data modify entity <target> <targetPath> prepend string storage <source> <sourcePath> <start> <end>
data modify entity <target> <targetPath> prepend value <value>
data modify entity <target> <targetPath> set from block <sourcePos> <sourcePath>
data modify entity <target> <targetPath> set from entity <source> <sourcePath>
data modify entity <target> <targetPath> set from storage <source> <sourcePath>
data modify entity <target> <targetPath> set string block <sourcePos> <sourcePath> <start> <end>
data modify entity <target> <targetPath> set string entity <source> <sourcePath> <start> <end>
data modify entity <target> <targetPath> set string storage <source> <sourcePath> <start> <end>
data modify entity <target> <targetPath> set value <value>
data modify storage <target> <targetPath> append from block <sourcePos> <sourcePath>
data modify storage <target> <targetPath> append from entity <source> <sourcePath>
data modify storage <target> <targetPath> append from storage <source> <sourcePath>
data modify storage <target> <targetPath> append string block <sourcePos> <sourcePath> <start> <end>
data modify storage <target> <targetPath> append string entity <source> <sourcePath> <start> <end>
data modify storage <target> <targetPath> append string storage <source> <sourcePath> <start> <end>
data modify storage <target> <targetPath> append value <value>
data modify storage <target> <targetPath> insert <index> from block <sourcePos> <sourcePath>
data modify storage <target> <targetPath> insert <index> from entity <source> <sourcePath>
data modify storage <target> <targetPath> insert <index> from storage <source> <sourcePath>
data modify storage <target> <targetPath> insert <index> string block <sourcePos> <sourcePath> <start> <end>
data modify storage <target> <targetPath> insert <index> string entity <source> <sourcePath> <start> <end>
data modify storage <target> <targetPath> insert <index> string storage <source> <sourcePath> <start> <end>
data modify storage <target> <targetPath> insert <index> value <value>
data modify storage <target> <targetPath> merge from block <sourcePos> <sourcePath>
data modify storage <target> <targetPath> merge from entity <source> <sourcePath>
data modify storage <target> <targetPath> merge from storage <source> <sourcePath>
data modify storage <target> <targetPath> merge string block <sourcePos> <sourcePath> <start> <end>
data modify storage <target> <targetPath> merge string entity <source> <sourcePath> <start> <end>
data modify storage <target> <targetPath> merge string storage <source> <sourcePath> <start> <end>
data modify storage <target> <targetPath> merge value <value>
data modify storage <target> <targetPath> prepend from block <sourcePos> <sourcePath>
data modify storage <target> <targetPath> prepend from entity <source> <sourcePath>
data modify storage <target> <targetPath> prepend from storage <source> <sourcePath>
data modify storage <target> <targetPath> prepend string block <sourcePos> <sourcePath> <start> <end>
data modify storage <target> <targetPath> prepend string entity <source> <sourcePath> <start> <end>
data modify storage <target> <targetPath> prepend string storage <source> <sourcePath> <start> <end>
data modify storage <target> <targetPath> prepend value <value>
data modify storage <target> <targetPath> set from block <sourcePos> <sourcePath>
data modify storage <target> <targetPath> set from entity <source> <sourcePath>
data modify storage <target> <targetPath> set from storage <source> <sourcePath>
data modify storage <target> <targetPath> set string block <sourcePos> <sourcePath> <start> <end>
data modify storage <target> <targetPath> set string entity <source> <sourcePath> <start> <end>
data modify storage <target> <targetPath> set string storage <source> <sourcePath> <start> <end>
data modify storage <target> <targetPath> set value <value>
data remove block <targetPos> <path>
data remove entity <target> <path>
data remove storage <target> <path>
Argumentos[]
<targetPos>
: block_pos
- La posición del objetivo entidad de bloque cuyo NBT se va a operar.
- It must be a block position composed of <x>, <y> and <z>, each of which must be an integer or a tilde and caret notation.
<target>
: entity (en modo entity <target>
)
- Especifica una entidad cuyo NBT se va a operar.
- MC-Arg desc: Illegal parameters
<target>
: resource_location (en modo storage <target>
)
- Especifica un almacenamiento en el que se va a operar.
- MC-Arg desc: Illegal parameters
<ruta>
: nbt_path
- Especifica el NBT que se recuperará o eliminará.
- Must be an NBT path.
<escala>
: doble
- Escalar para el valor de retorno del comando.
- MC-Arg desc: Illegal parameters
<nbt>
: nbt_compound_tag
- Especifica una etiqueta compuesta que se fusionará en algún lugar.
- Must be a compound NBT in SNBT format.
<targetPath>
: nbt_path
- Especifica el NBT objetivo que se va a modificar.
- Must be an NBT path.
<índice>
: entero
- Especifica el índice de un objeto dentro de una lista.
- MC-Arg desc: Illegal parameters
<sourcePos>
: block_pos
- La posición del objetivo entidad de bloque cuyo NBT se va a utilizar.
- It must be a block position composed of <x>, <y> and <z>, each of which must be an integer or a tilde and caret notation.
<fuente>
: entidad (en modo entidad <fuente>
)
- Especifica una entidad cuyo NBT será utilizado por
modify
. - MC-Arg desc: Illegal parameters
<source>
: resource_location (en modo storage <source>
)
- Especifica un almacenamiento que utilizará
modify
. - MC-Arg desc: Illegal parameters
<sourcePath>
: nbt_path
- Especifica el NBT de origen que utilizará
modify
. - Must be an NBT path.
<inicio>
: entero
- Especifica el índice del primer carácter que se incluirá al inicio de la cadena. Los valores negativos se interpretan como un índice contado desde el final de la cadena.
- MC-Arg desc: Illegal parameters
<fin>
: entero
- Especifica el índice del primer carácter a excluir al final de la cadena. Los valores negativos se interpretan como un índice contado desde el final de la cadena.
- MC-Arg desc: Illegal parameters
<valor>
: nbt_tag
- Valor utilizado para modificar el NBT objetivo. Debe coincidir con su tipo de datos.
- Must be an NBT tag of any type in SNBT format.
Resultado[]
Comando | Provoca | Java Edition |
---|---|---|
cualquiera | los argumentos no están especificados correctamente | no analizable |
<targetPos> está descargado o fuera del mundo | Falla | |
el bloque en <targetPos> no es una entidad de bloque | ||
<target> (en modo entity <target> ) no se resuelve en una entidad (el jugador nombrado debe estar en línea) | ||
/data get... | se tiene m��s de una etiqueta | |
/data get... <ruta> | <ruta> no existe | |
/data get... <ruta> <escala> | la etiqueta obtenida no es una etiqueta numérica | |
/data merge... | no se cambia nada | |
intenta editar los datos del jugador | ||
/data remove... | <path> es la etiqueta raíz compuesta | |
/datamodify... (from|string) block... | <sourcePos> está descargado o fuera del mundo | |
el bloque en <sourcePos> no es una entidad de bloque | ||
/datamodify... (from|string)entity... | <sourceEntity> no se resuelve en una entidad (el jugador nombrado debe estar en línea) | |
/data modificar... (from|string)... <sourcePath> | <sourcePath> no existe | |
/datamodify... string... <sourcePath> <start> <end> | <sourcePath> no es una cadena o etiqueta numérica (se convertirá a una cuerda) | |
<start> or <end> no tiene índices válidos de la cadena fuente | ||
El carácter indexado por <start> está detrás del indexado por <end> | ||
/datos modificar... anexar... | el objetivo la etiqueta no es una lista o matriz | |
los datos de origen no son de un tipo de elemento apropiado para la lista | ||
/datos modificar... insertar <índice>... | el índice no es válido | |
/data modificar... fusionar... | la ruta de destino no especifica una etiqueta compuesta | |
los datos fuente no son una etiqueta compuesta | ||
cualquiera | Al ejecutarse exitosamente |
Salida[]
Comando | Edición | Situación | Contador de éxitos | /execute store success ... | /execute store result ... |
---|---|---|---|---|---|
cualquiera | Java Edition | En caso de fallo | 0 | 0 | 0 |
/data get ... | Sobre el éxito | 1 | 1 | 1 | |
/data get ... <path> | se obtiene una etiqueta numérica | 1 | 1 | el valor obtenido después de redondear hacia abajo[1] | |
se obtiene una etiqueta de lista o matriz | 1 | 1 | El número de elementos en esta lista o matriz | ||
se obtiene una etiqueta de cadena | 1 | 1 | La longitud de la cadena | ||
se obtiene una etiqueta compuesta | 1 | 1 | El número de etiquetas que son hijos directos de ese compuesto | ||
/data get ... <path> <scale> | Sobre el éxito | 1 | 1 | el valor obtenido se multiplica por <scale> , luego se redondea hacia abajo[2] | |
/data merge ... | Sobre el éxito | 1 | 1 | 1 | |
/data remove ... | Sobre el éxito | 1 | 1 | 1 | |
/datos modificar... append... | Sobre el éxito | 1 | 1 | el número de listas o matrices a las que se agregan nuevos elementos | |
/data modificar... set... | Sobre el éxito | 1 | 1 | el número de etiquetas de destino que se modificaron exitosamente | |
/data modificar... fusionar... | Sobre el éxito | 1 | 1 | el número de etiquetas compuestas de destino que se modificaron con éxito |
Ejemplos[]
- Para obtener el nivel de saturación del reproductor actual:
/data get entidad @s foodSaturationLevel
- Para que los jugadores no puedan recoger el objeto más cercano dentro de 10 bloques:
/datos modificar entidad @e[type=item,distance=..10,limit=1,sort=nearest] PickupDelay establece valor -1
- Para obtener la posición Y de un objeto aleatorio:
/data get entidad @e[type=item,limit=1,sort=random] Pos[1]
- Para obtener el ID del objeto en el primer espacio de la barra de acceso rápido del jugador más cercano:
/data get entidad @p Inventario[{Slot:0b}].id
- Para establecer la armadura atributo del delfín más cercano a las coordenadas (0, 64, 0) en 20:
/entidad de modificación de datos @e[x=0,y=64,z=0,type=dolphin,limit=1] Atributos[{Name:"minecraft:generic.armor"}].Valor del conjunto base 20
- Para cambiar el primer objeto en un cofre ubicado en las coordenadas (1, 64, 1) en un bloque de diamantes, manteniendo todos los datos NBT:
/datos modificar bloque 1 64 1 Items[0].id establecer valor "minecraft:diamond_block"
- Para hacer que el zombie más cercano tenga un 80% de probabilidad de soltar objetos en su mano secundaria cuando muera, y nunca soltar objetos en la mano principal:
/entidad de fusión de datos @e[tipo=zombie,limit=1,sort=más cercano] {HandDropChances: [0f, 0.8f]}
- Para hacer que el zombie más cercano tenga un 80% de probabilidad de soltar objetos en su mano secundaria cuando muera, sin afectar la probabilidad de la mano principal:
/datos modifica entidad @e[type=zombie,limit=1,sort=nearest] HandDropChances[1] establece valor 0.8f
Almacenamiento[]
El almacenamiento de comandos de datos NBT es una manera eficiente para que commands acceda o guarde datos NBT sin una sobrecarga para entidades de bloque o entidades leer o escribir en los datos NBT .
Cada almacenamiento de comandos es un almacenamiento clave-valor de propósito general, identificado por una ubicación del recurso para evitar conflictos involuntarios.
/data get
y /data modifi
pueden leer desde el almacenamiento, mientras que /data merge
, /data modificar
, /data remove
y /execute store
pueden escribir en el almacenamiento.
Una matriz de almacenamiento puede contener hasta 2304 objetos antes de alcanzar su límite máximo.
También se puede acceder al almacenamiento de comandos con texto JSON.
Historial[]
Java Edition | |||||
---|---|---|---|---|---|
1.13 | 17w45b | Se agregó /data . | |||
17w47a | Commands /blockdata and /entitydata have been removed as their features are merged into /data . | ||||
18w03a | Usar /data get (block|entity|storage) con una ruta ahora funciona con valores no numéricos. | ||||
1.14 | 18w43a | Se agregó /data modify (block|entity|storage) . | |||
1.15 | 19w38a | Se agregó storage <ubicación del recurso> como origen o destino. | |||
1.19.4 | 23w03a | Se agregó string fuente. | |||
1.20 | Prerelease 1 | Ahora <start> o <end> en la fuente string aceptan límites negativos, que se interpretan como índice contado desde el final de la cadena. | |||
Prerelease 2 | Ahora <start> o <end> no válidos en la fuente string resultan en una falla del comando en lugar de no ser controlados error.[3] |
Referencias[]
Plantilla:Reflist
- ↑ doble n = (doble)valor;
int salida = n < (int)n? (int)n - 1 :(int)n;
Ver también MC-259032 - ↑ doble n = (doble) valor * escala;
int salida = n < (int)n? (int)n - 1 :(int)n;
Ver también MC-259032 - ↑ MC-260602 – "/la modificación de datos debido a un error en el índice de cadena no devuelve 0 para/ejecutar correctamente el almacenamiento." – Resuelto como "Fixed"