6

I am making a Minecraft Mini Game adventure map, and one of the levels has a /setblock command, I am using the command in a way to spawn an item in a chest (Wooden Button) I need the wooden button to have CanPlaceOn tag so it can be placed on a log.

I have tried: /setblock 294 5 -1251 minecraft:chest 0 replace {Items:[:{Count:1,Slot:0,id:minecraft:wooden_button,CanPlaceOn:[log]}]}

3

The CanPlaceOn list is inside the tag compound tag:

/setblock 294 5 -1251 minecraft:chest 0 replace {Items:[{Count:1,Slot:0,id:minecraft:wooden_button,tag:{CanPlaceOn:[log]}}]}

Item NBT structure can be found on this wiki page.

| improve this answer | |
  • @ExpertCoder14 I believe your edit deviates from the original intent of the answer, since the command in the question doesn't use quotes or data types, and they don't appear to be necessary for the command to work. – pppery Jul 5 at 2:02
  • In any case, I would like to request SirBenet to put the edits in revision 2 through, so that they follow the standards for retrieving the NBT tags. It’s better to teach the correct way and learn the shortcut later, rather than having to get used to the correct way later when it’s required. – ExpertCoder14 Jul 5 at 2:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.