0

I want to get the NBT data of a block as a string e.g. The NBT data of a chest. I know that this is possible as I had to do it a year or so ago for a key to a house I had built.

1
  • 1
    Do you want to get the NBT data and store it as a string somehow, or just see it in chat?
    – SirBenet
    Aug 27, 2016 at 23:50

3 Answers 3

2

You can use the /blockdata command to see tile entity data. Providing no input will show the current state of that data. For instance, stand on top of a chest and run the following:

/blockdata ~ ~-1 ~ {}
1

This way isn't very efficient, but it's how I have always done it (and I don't know another way):

  1. Look at the chest, hold ctrl, and press your pick block button (configurable in options). This should give you a chest item with identical NBT data.

  2. Place a command block down anywhere that doesn't have armor stands adjacent to it (including diagonally)

  3. Run the command using the command block:

    /summon ArmorStand ~ ~ ~ {ShowArms:1}
    
  4. Then put the chest item in the hand of the armor stand, then run this command in the command block:

    /entitydata @e[type=ArmorStand,c=1] {}
    
  5. You can then go to the output of the command block, look for the Items tag and copy the text within the following '['. Alternatively, you can copy the whole output, paste it in a text editor, press ctrl + F, and search for the tag.

An example of what I would copy is:

Items:[0:{Slot:0b,id:"minecraft:sandstone",Count:1b,Damage:0s}
0

Just in case, as of ItemsAdder 3.4.1-r4, the following command should return entity data, including NBT, of an item currently being held by a player Player1:

/data get entity @p[name=Player1] SelectedItem

If it does not output anything in-game, you might want to try it on the server console.


Related: How can I see the entity data of an existing item?

You must log in to answer this question.

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