How can I make a tool drop blocks with CanPlaceOn tag

Run a execute command on all players that are holding the tool which sets the tag on all items you want the tag on:

Run these once:

/scoreboard objectives add holdingTool dummy
/scoreboard objectives add tagItem dummy
/scoreboard objectives add life stat.timeSinceDeath

Run these on a clock:

/scoreboard players set @a holdingTool 0
/scoreboard players set @a holdingTool 1 {SelectedItem:<Tool>}
/scoreboard players set @e[type=Item] tagItem 0
/scoreboard players set @e[type=Item,score_life=1] tagItem 1 {Item:<Data Tags of Item>}
/execute @a[score_holdingTool_min = 1] ~ ~ ~ entitydata @e[score_tagItem_min = 1,r=5] {Item:{tag:{CanPlaceOn:["<Block That Can Be Placed On>"]}}}

This will run the entitydata command on all items around players in a 5 block range with the holdingTool tag of 1, aka all players who have the specific tool selected. the entitydata command will only affect items of the correct type that has just spawned.


Use a /fill clock hooked up to three command blocks to add the tag to item entities. Unfortunately, I don't know if it's possible to limit this to only those created with a specific tool.

First, create a scoreboard objective to keep track of the items you'll be adding the tag to.

/scoreboard objectives add itemID dummy

The first command block (order of execution does matter) in the fill clock will reset the objective for all item entities currently loaded.

/scoreboard players set @e[type=Item] itemID 0

The second sets the score based upon item id. Note that you can affect different types of items by assigning different values.

/scoreboard players set @e[type=Item] itemID 1 {Item:{id:minecraft:stone}}

Lastly, add the CanPlaceOn tag to all items with the right score.

/entitydata @e[score_itemID_min=1,score_itemID=1] {Item:{tag:{CanPlaceOn:["minecraft:stone"]}}}