In my Minecraft world I am building a map and in this map I need to be able to give the player a lever that can be placed on only one block of my choice (like a gold block for instance).

I tried these commands in a command block

give @p lever 1 0 {CanPlaceOn:[“gold_block”]}
give @p lever 1 0 {CanPlaceOn:[“minecraft:gold_block”]}
give @p lever 1 0 {CanPlaceOn:[gold_block]}
give @p lever 1 0 {CanPlaceOn:[“Block:gold_block]}

All of them give me an error at the syntax past the CanPlaceOn:[ (copy/paste them into your world and you’ll see what I mean).

What am I doing wrong? I've checked all over the internet and it seems there aren’t any really clear guides on how to do this (and I know it can be done because there is a map on mcpedl.com that is called “Escape!” and you get a lever that can only be placed on gold blocks).

  • This is a Q&A site, so you should make your "update" into an answer to your own question and then mark it as "accepted answer". Otherwise this stays open and will at some point be bumped to the homepage again to ask for answers. – Fabian Röling Oct 8 '17 at 20:36
  • ...aaaaand it just happened – Zelo101 Jan 12 '18 at 19:20
  • You aren’t using the correct way of naming blocks. MCPE uses json instead of NBT – Detmondyou May 2 '18 at 23:56
  • 5

This is the proper command syntax for MCPE:

/give @p lever 1 0 {"can_place_on":{"blocks":["gold_block"]}}

You can change the block or placeable item after the /give @p lever but it has to be a placeable item.

Also changing the block or adding more do this:

  • To change the block you want to place it on, just change the string inside the square brackets after {"blocks":["**this string here**"]}}.

  • Adding more blocks:

    /give @p lever 1 0 {"can_place_on":{"blocks":["gold_block", "iron_block"]}}

| improve this answer | |

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