How to summon chest with button that can be placed on stone in minecraft?
Solution 1:
There are two issues in your command.
/setblock 776 74 363 chest 0 replace {
Items: [
{
id: "stone_button",
Slot: 13,
Count: 1,
CanPlaceOn: "stone" // specifically, this line
}
]
}
1
The CanPlaceOn
tag syntax specifies that it accepts an array of strings:
{CanPlaceOn:[
"<ID>",
"<another ID>",...
]}
(Note the pair of square brackets.) Therefore, it is necessary to enclose the block ID(s) in []
.
2
The Item
tag syntax is as follows:
{Item:{
id:"<ID>",
Damage:<int>,
Count:<int>,
tag:{
<Item NBT data here>
}
}}
The syntax specifies that you need to put NBT tags of the item within the tag:
tagname. Since CanPlaceOn
is an NBT tag of an item, you need to enclose it with tag:{}
.
tldr
The correct command is as follows:
setblock 776 74 363 chest 0 replace {
Items: [
{
id: "stone_button",
Slot: 13,
Count: 1,
tag:{
CanPlaceOn: ["minecraft:stone"]
}
}
]
}
This has been tested in a 1.11.2 singleplayer world.