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.
What is most likely happening is that you don't have an armor stand named ASCounter. The best way to test what is actually happening is by doing the command separate from the execute, so
/scoreboard players add @e[type=ArmorStand,name=ASCounter] counter 1
Then it will tell what is happening wrong.
Best Answer
You can have a tag that tells you if a player was recently holding a water bottle. These commands work for me, I put the first one into a repeating command block and the rest into chain command blocks:
The first command tags any player who is holding a water bottle
The second command removes the tag from any player who is not holding a water bottle, unless they just used a potion
The third command executes a command as any player who was just drinking a potion and has the
holdsWater
tagThe last command resets the scoreboard objective
drinkPotion