/data
/data
Nível de permissão exigido |
2 |
---|---|
Restrições |
Nenhuma |
{ "title": "<code>/data</code>", "rows": [ { "field": "2", "label": "(link to Nível de permissão article, displayed as Nível de permissão<br />exigido)" }, { "field": "Nenhuma", "label": "(link to Comandos#Restrições article, displayed as Restrições)" } ], "invimages": [], "images": [] }
Permite que o usuário obtenha, mescle, modifique e remova dados NBT de um bloco-entidade, entidade ou armazenamento de comandos NBT.
Sintaxe[editar | editar código-fonte]
Há quatro instruções para /data
(get
, merge
, modify
, remove
), e os destinos/fontes referenciados por cada comando de instrução podem ser block <targetPos>
, entity <target>
ou storage <target>
.
/data ...
... get
... (block <targetPos>|entity <target>|storage <target>) [<path>] [<scale>]
- Ler todos os dados NBT ou a subseção dos dados NBT da posição do bloco ou entidade de destino para o executor com destaque de sintaxe, dimensionado por
<scale>
, se especificado.
- Ler todos os dados NBT ou a subseção dos dados NBT da posição do bloco ou entidade de destino para o executor com destaque de sintaxe, dimensionado por
... merge
... (block <targetPos>|entity <target>|storage <target>) <nbt>
- Mescla os dados NBT da posição do bloco de destino ou entidade com os dados
<nbt>
especificados.
- Mescla os dados NBT da posição do bloco de destino ou entidade com os dados
... modify (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>
- Anexe os dados de origem ou os dados de valor direto ao fim da lista ou matriz apontada.
... 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>
- Insire os dados de origem ou dados de valor direto na lista ou matriz apontada como elemento
<index>
e, em seguida, desloca os elementos mais altos uma posição acima.
- Insire os dados de origem ou dados de valor direto na lista ou matriz apontada 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>
- Mescla os dados de origem ou os dados de valor direto no objeto apontado.
... prepend from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]
... prepend string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]
... prepend value <value>
- Adiciona os dados de origem ou os dados de valor direto ao início da lista ou matriz apontada.
... set from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]
... set string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]
... set value <value>
- Define a marcação especificada por
<targetPath>
para os dados de origem ou dados de valor direto.
- Define a marcação especificada por
... remove
... (block <targetPos>|entity <target>|storage <target>) <path>
- Remove dados NBT em
<path>
da posição do bloco ou entidade destino. Dados NBT do jogador não podem ser removidos.
- Remove dados NBT em
Sintaxe exibida de várias maneiras
Árvore simplificada: [exibir] /data
- onde os argumentos substituídos são:
<TARGET>
=(block <targetPos> | entity <target> | storage <target>)
<MODIFICATION>
=(append|insert <index>|merge|prepend|set)
<SOURCE>
=(block <sourcePos> | entity <source> | storage <source>)
Árvore esmagada: [exibir] /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>
Maximizada: [exibir] 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[editar | editar código-fonte]
<targetPos>
: block_pos
- A posição do bloco-entidade destino cujo NBT deve ser operado.
- Isso deve ser um bloco de posição composto de <x>, <y> e <z>, cada um deles deve ser um número inteiro ou notação de til e circunflexo.
<target>
: entity (no modo entity <target>
)
- Especifica uma entidade cujo NBT deve ser operado.
- Deve ser um nome de jogador, seletores de destino ou o UUID. E o seletor de destino deve ser de tipo único.
<target>
: resource_location (no modo storage <target>
)
- Especifica um armazenamento a ser operado.
- Deve ser uma localização de recurso.
<path>
: nbt_path
- Especifica o NBT a ser recuperado ou removido.
- Deve ser um caminho NBT.
<scale>
: double
- Escala para o valor de saída do comando.
- Deve ser um Número de ponto flutuante com dupla precisão (de -(2-2-52)×21023 (≈-1,8×10308) a (2-2-52)×21023 (≈1,8×10308) ).
<nbt>
: nbt_compound_tag
- Especifica uma marcação composta a ser mesclada em algum lugar.
- Deve ser um composto NBT no formato SNBT.
<targetPath>
: nbt_path
- Especifica o NBT de destino a ser modificado.
- Deve ser um caminho NBT.
<index>
: integer
- Especifica o index de um item dentro de uma lista.
- Deve ser um Número inteiro de 32 bits (de -2147483648 (-231) a 2147483647 (231-1) ).
<sourcePos>
: block_pos
- A posição do bloco-entidade alvo cujo NBT deve ser usado.
- Isso deve ser um bloco de posição composto de <x>, <y> e <z>, cada um deles deve ser um número inteiro ou notação de til e circunflexo.
<source>
: entity (no modo entity <source>
)
- Especifica uma entidade cujo NBT deve ser usado por
modify
. - Deve ser um nome de jogador, seletores de destino ou o UUID. E o seletor de destino deve ser de tipo único.
<source>
: resource_location (no modo storage <source>
)
- Especifica um armazenamento a ser usado por
modify
. - Deve ser uma localização de recurso.
<sourcePath>
: nbt_path
- Especifica o NBT de origem a ser usado por
modify
. - Deve ser um caminho NBT.
<start>
: integer
- Especifica o index do primeiro caractere a ser incluído no início da string. Valores negativos são interpretados como index contado a partir do fim da string.
- Deve ser um Número inteiro de 32 bits (de -2147483648 (-231) a 2147483647 (231-1) ).
<end>
: integer
- Especifica o index do primeiro caractere a ser excluído no final da string. Valores negativos são interpretados como index contado a partir do final da string.
- Deve ser um Número inteiro de 32 bits (de -2147483648 (-231) a 2147483647 (231-1) ).
<value>
: nbt_tag
- Valor usado na modificação do NBT destino.
- Deve ser uma marcação NBT de qualquer tipo no formato SNBT.
Resultado[editar | editar código-fonte]
Comando | Circunstância | Edição Java |
---|---|---|
Qualquer | O comando está incompleto ou algum argumento não foi especificado corretamente. | Não analisável |
<targetPos> está descarregado ou fora do mundo. | Falha | |
O bloco em <targetPos> não é um bloco-entidade. | ||
<target> (no modo entity <target> ) falha ao resolver para uma única entidade (o jogador nomeado deve estar online). | ||
/data get ... | Mais de uma marcação foi obtida. | |
/data get ... <path> | Nenhuma marcação existe em <path> . | |
/data get ... <path> <scale> | A marcação obtida não é uma marcação numérica. | |
/data merge ... | Nada foi alterado. | |
Tenta editar os dados de um jogador. | ||
/data remove ... | <path> seleciona a marcação composta raiz. | |
/data modify ... (from|string) block ... | <sourcePos> está descarregado ou fora do mundo. | |
O bloco em <sourcePos> não é um bloco-entidade. | ||
/data modify ... (from|string) entity ... | <source> falha na resolução para uma única entidade (o jogador nomeado deve estar online). | |
/data modify ... (from|string) ... <sourcePath> | Nenhuma marcação existe em <sourcePath> . | |
/data modify ... string ... <sourcePath> <start> <end> | Nenhuma das marcações selecionadas por <sourcePath> é uma marcação de string ou numérica (será convertida em string). | |
<start> ou <end> está fora do index válido de qualquer uma das strings de origem. | ||
Para qualquer uma das strings de origem, o caractere indexado por <start> está atrás daquele indexado por <end> . | ||
/data modify ... append ... | Nenhuma das marcações de destino é uma marcação de lista ou matriz. | |
Nem todas as marcações de origem são do tipo apropriado para todas as listas ou matrizes de destino. | ||
/data modify ... insert <index> ... | O index é inválido para todas as listas ou matrizes de destino. | |
/data modify ... merge ... | Nenhuma das marcações de destino é uma marcação composta. | |
Nenhuma das marcações de origem é uma marcação composta. | ||
Qualquer | De outra forma | Bem-sucedido |
Saída[editar | editar código-fonte]
Comando | Edição | Situação | Contagem de sucesso | /execute store succeess ... | /execute store result ... |
---|---|---|---|---|---|
qualquer | Edição Java | Em caso de falha | 0 | 0 | 0 |
/data get ... | Em caso de sucesso | 1 | 1 | 1 | |
/data get ... <path> | Uma marcação numérica é obtida | 1 | 1 | O valor obtido após arredondamento para baixo[1] | |
Uma marcação de lista ou matriz é obtida | 1 | 1 | O número de elementos nesta lista ou matriz | ||
Uma marcação de string é obtida | 1 | 1 | O comprimento da string | ||
Uma marcação composta é obtida | 1 | 1 | O número de marcações que são filhos diretos desse composto | ||
/data get ... <path> <scale> | Em caso de sucesso | 1 | 1 | O valor obtido multiplicado por <scale> e arredondado para baixo[2] | |
/data merge ... | Em caso de sucesso | 1 | 1 | 1 | |
/data remove ... | Em caso de sucesso | 1 | 1 | 1 | |
/data modify ... append ... | Em caso de sucesso | 1 | 1 | O número de listas ou matrizes nas quais novos elementos são adicionados | |
/data modify ... set ... | Em caso de sucesso | 1 | 1 | O número de marcações de destino que foram modificadas com sucesso | |
/data modify ... merge ... | Em caso de sucesso | 1 | 1 | O número de marcações de compostos de destino que foram modificadas com sucesso |
Exemplos[editar | editar código-fonte]
- Para obter o nível de saturação do jogador atual:
/data get entity @s foodSaturationLevel
- Para fazer com que o item mais próximo dentro de 10 blocos não possa ser pego pelos jogadores:
/data modify entity @e[type=item,distance=..10,limit=1,sort=nearest] PickupDelay set value -1
- Para obter a posição Y de um item aleatório:
/data get entity @e[type=item,limit=1,sort=random] Pos[1]
- Para obter o ID do item no primeiro espaço da barra rápida do jogador mais próximo:
/data get entity @p Inventory[{Slot:0b}].id
- Para definir o atributo de defesa do golfinho mais próximo das coordenadas (0, 64, 0) para 20:
/data modify entity @e[x=0,y=64,z=0,type=dolphin,limit=1] Attributes[{Name:"minecraft:generic.armor"}].Base set value 20
- Para transformar o primeiro item em um baú localizado nas coordenadas (1, 64, 1) em um bloco de diamante, mantendo todos os dados NBT:
/data modify block 1 64 1 Items[0].id set value "minecraft:diamond_block"
- Para fazer com que o zumbi mais próximo tenha 80% de chance de largar os itens em sua mão secundária quando morrer, e nunca largar os itens na mão principal:
/data merge entity @e[type=zombie,limit=1,sort=nearest] {HandDropChances: [0f, 0.8f]}
- Para fazer com que o zumbi mais próximo tenha 80% de chance de largar os itens em sua mão secundária quando morrer, sem afetar a chance da mão principal:
/data modify entity @e[type=zombie,limit=1,sort=nearest] HandDropChances[1] set value 0.8f
Comprimento de lista, matriz e string[editar | editar código-fonte]
Com /data get
, é possível obter o comprimento de listas ou matrizes e o número de caracteres em strings, já que seu valor de retorno é o comprimento da string, lista ou matrizes sendo referenciados. Esse valor pode então ser armazenado usando /execute store
, se necessário.
- Exemplo de lista
Suponha que uma lista seja armazenada usando o seguinte comando:
/data merge storage wiki:example {List:[2,5,8,9,6,10]}
Então, executar o comando a seguir retorna 6
, o comprimento da lista:
/data get storage wiki:example List
- Exemplo de string
Suponha que uma string seja armazenada usando o seguinte comando:
/data merge storage wiki:example {String:"Example string with a character count of 43"}
Em seguida, executar o comando a seguir retorna 43
, o comprimento da string:
/data get storage wiki:example String
Histórico[editar | editar código-fonte]
[ocultar]Edição Java | |||||||
---|---|---|---|---|---|---|---|
1.13 | 17w45b | /data foi adicionado. | |||||
17w47a | Os comandos /blockdata e /entitydata foram removidos, pois seus recursos foram mesclados em /data . | ||||||
18w03a | Usar /data get (block|entity|storage) com um caminho agora funciona em valores não numéricos. | ||||||
1.14 | 18w43a | /data modify (block|entity|storage) foi adicionado. | |||||
1.15 | 19w38a | storage <localização de recurso> foi adicionado como fonte ou destino. | |||||
1.19.4 | 23w03a | A fonte string foi adicionada. | |||||
1.20 | Pre-release 1 | Agora <start> ou <end> na fonte string aceitam limites negativos, que são interpretados como index contado a partir do final da string. | |||||
Pre-release 2 | Agora, <start> ou <end> inválidos na fonte string resultam em uma falha de comando em vez de um erro não processado.[3] |
Referências[editar | editar código-fonte]
- ↑ double n = (double)value;
int output = n < (int)n ? (int)n - 1 :(int)n;
Veja também MC-259032 - ↑ double n = (double)value * scale;
int output = n < (int)n ? (int)n - 1 :(int)n;
Veja também MC-259032 - ↑ MC-260602 — /data modify from string index falhando não retorna 0 para /execute store success. — resolvido como "Corrigido".