Minecraft – /blockdata command help

minecraft-commandsminecraft-java-edition

I wrote this command to make a chest constantly replace the items inside itself, the problem is that the command worked for the first part (command block) but if I try to add a second item like the button the command stops working.

How can I solve this problem?

Command:

/blockdata 3 56 0 {Items:[{id:137,Count:1,Slot:12,tag:{HideFlags:1,Unbreakable:1,display:{Name:"Command Block",Lore:["Write Commands Here!"]},ench:[{id:4,lvl:2}]}}],[{id:143,Count:1,Slot:13,tag:{HideFlags:1,Unbreakable:1,display:{Name:"Button",Lore:["Activate Commands!"]},ench:[{id:4,lvl:2}]}}]}

Best Answer

A single item should be an unnamed compound tag and, for a chest, all items should be contained within the same list as each other called "Items". Compound tags use curly brackets: { }, and lists use square brackets: [ ].

Currently, your problem is that you have each item in its own list, when they should both be in the "Items" list.

You are also using numeric IDs which won't work in future versions.

The correct command should be:

/blockdata 3 56 0 {Items:[{id:command_block,Count:1,Slot:12,tag:{HideFlags:1,Unbreakable:1,display:{Name:"Command Block",Lore:["Write Commands Here!"]},ench:[{id:4,lvl:2}]}},{id:stone_button,Count:1,Slot:13,tag:{HideFlags:1,Unbreakable:1,display:{Name:"Button",Lore:["Activate Commands!"]},ench:[{id:4,lvl:2}]}}]}

Essentially, I've changed:

Items:[{command block item info}],[{button item info}]

To:

Items:[{command block item info},{button item info}]