3

I have a problem I want to create a chest that will have a button inside and this button can be placed on stone block. Can someone give me the command? I was trying this: (No Error) It was placing chest with button but this button hasn't got option to place it on stone.

/setblock 776 74 363 chest 0 replace {
    Items: [
        {
            id: "stone_button",
            Slot: 13,
            Count: 1,
            CanPlaceOn: "stone"
        }
    ]
}
13
  • Are you on Java edition? Mar 13, 2019 at 17:00
  • 2
    Possible duplicate of How do I tag a named item on the ground Mar 13, 2019 at 18:40
  • 2
    The dupe target has been closed for being unclear, it might be better to provide an answer on this question instead, as this question is more easy to understand. Other Q might then be set as Dupe of this one.
    – Malco
    Mar 14, 2019 at 14:13
  • 3
    Given that the proposed dupe target is closed and has 1 pending delete vote, I am strongly against closing this question as a duplicate.
    – Unionhawk
    Mar 14, 2019 at 16:11
  • 2
    The linked question also doesn't really answer this question. Yes, someone that has some experience can glean the answer to this question from that answer, but it isn't a straight path from one to the other.
    – MBraedley
    Mar 14, 2019 at 16:37

2 Answers 2

2

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.

0

I dont think you can make items with special features on them What you have to do is create the button and make it place on stone and then put the button in the chest

You must log in to answer this question.

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