Unfortunately, the CanPlaceOn tag does not support Damage values as of yet. The syntax of that tag will only accept an array of strings that correspond to block names, therefore you cannot make the item be placed only on a specific colour, only hardened clay in general.
Also, you are currently trying to set a Damage value to the block to be placed rather than the block it should be placed on.
You'll need to "translate" the glass bottle data tag into something that works with target selectors (@a and so on). This can be achieved most easily using dummy scoreboard values or, in 1.9, scoreboard tags.
In 1.8, create an objective using
scoreboard objectives add bottleInOne dummy
Create a fill clock and run the following two commands
scoreboard players set @a[score_bottleInOne_min=1] bottleInOne 0
scoreboard players set @a[score_bottleInOne=0] bottleInOne 1 {SelectedItemSlot:0,SelectedItem:{id:minecraft:glass_bottle}}
If the team part is necessary, you can now add @a[score_bottleInOne_min=1]
to the team, and remove @a[score_bottleInOne=0]
from it, using the same fill clock. You could also use these target selectors directly for the /effect
and /replaceitem
commands, if the team part was just your idea of selecting that player for the effect.
In 1.9, you can omit the scoreboard objective in favor of tags. Using a Repeat/Chain command block chain, run
scoreboard players tag @a[tag=bottleInOne] remove bottleInOne
scoreboard players tag @a[tag=!bottleInOne] add bottleInOne {SelectedItemSlot:0,SelectedItem:{id:minecraft:glass_bottle}}
In the following commands, you can then use @a[tag=bottleInOne]
or @a[tag=!bottleInOne]
to target players with and without the bottle selected in slot 0, respectively.
Best Answer
Best way I can think of is teleporting the player backwards if they don't have the key and are in the blocked off area. So you'd use an invisible armor stand to mark the places these "blocks" would be. Then create a scoreboard objective that indicates if the player has the key. Every tick of a fill clock (or, in the 1.9 snapshots, of a repeating command block), you'd reset everyone's score to 0, then set the score to 1 for players who have the correct item in their inventory, as checked by their Inventory data tag (see http://minecraft.gamepedia.com/Player.dat_format#NBT_structure for more information about the format of the Inventory tag). Then you execute on each of your "invisible block" armor stands to /tp every player in radius 0 with a score of 0 back a block or two.