In Minecraft I'm able to determine the id of the first item in a chest with the following command:

/data get block <chest coordinates> Items[0].id

which returns the id as string value. For example if the chest contained stone, the value returned would be "minecraft:stone". I'd like to used this returned value in other commands

For instance you can set an area to be stone with the command:

/fill <start coordinates> <end coorinates> minecraft:stone

What I'd like to do is something to the effect of:

/fill <start coordinates> <end coorinates> run data get block <chest coordinates> Items[0].id

but this doesn't work. I assume I just have the syntax wrong, but I can't find anything online to give me any guidance.

TLDR: Is there a way to use string values derived from a /data command, in other commands?

1 Answer 1


Minecraft does not have good string handling (yet, I assume that will change soon). A command like you imagined it would be great, but doesn't exist. The best you could do would be hardcoding many different values for blocks and have one fill command for each of them.

In your case it might potentially be possible to summon an army of endermen, give them all the block by moving the NBT over, then forcing them to stay in one place until they put the block down. But I guess that's harder than just hardcoding a few different blocks. :D

  • Now that I think about it more, there must be no good way to do it, otherwise Sethbling would have done it already for BlingEdit. Be requires you to use /setblock and then clones it. You could also summon a thousand endermen in one place and as soon as one of them places down its block, clone it everywhere. That should usually work pretty quickly, except that it also causes a lot of lag. And it still depends on chance. May 14, 2019 at 6:04
  • You can do fun things with copying NBT data, but unfortunately, even that new functionality isn't enough to accomplish this.
    – MBraedley
    May 14, 2019 at 12:34
  • BTW, there are actually ways to manipulate strings in Minecraft, but they are extremely complicated and rely on weird quirks. I don't fully understand them myself. Apr 18, 2022 at 10:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .