Place-able and breakable block in Adventure Mode [duplicate]

I am making my Adventure map, and i have one problem. I want to create a block what can be placed on diamond ore, for example, and when player destroy it, he could place it again.


Solution 1:

Using certain tags when using the /give command in minecraft you can allow certain blocks/tools to be placed/broken To break blocks:

/give @p minecraft:stone_shovel 1 0 {CanDestroy:[minecraft:dirt, minecraft:gravel, minecraft:soulsand]}

The gravel, dirt, and soulsand can be replaced with your desired blocks to be able to break.

To place:

/give @p minecraft:gravel 1 0 {CanPlaceOn:["minecraft:stone","minecraft:stonebrick"]}

This will allow the player to only place the block on "stone" and "stone brick"

To be more advanced you could run a testfor when the player breaks an item it could execute the command:

/give @p minecraft:gravel 1 0 {CanPlaceOn:["minecraft:stone","minecraft:stonebrick"]}

Then when they break the block they would get the block, and have it able to be placed on specific blocks.

Lets say that your "block" is emerald ore, you can give them an item/tool like this:

/give @p minecraft:diamond_pickaxe 1 0 {CanDestroy:[minecraft:emerald_ore]}

Then you could testfor that the emerald ore has been broken. Then you could execute the command:

/give @p minecraft:gravel 1 0 {CanPlaceOn:["minecraft:diamond_ore"]}

There you go!