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.
You don't have to use a selector for a playerscore. You can use any name you want, even if it's not a valid player's name. For instance, the following sets the score of a fake player named "pool":
/scoreboard players add pool money 10
Do keep in mind that if a player named "pool" joins, they will essentially "own" that score. You'd want to be careful when manipulating the scores in case their existence causes a conflict (such as running /scoreboard players add @a money 10
). If you prepend the name with "#" (such as "#pool"), the name will not appear on the sidebar and also prevents naming conflicts because real players cannot have the "#" character in their name.
As for your mechanism, you'll want to use Chain command blocks, which directly specifies activation order, instead of comparators, which does not have a guaranteed activation order and causes delay. The delay can cause the mechanism to lock up if a player kills a zombie before the comparator turns off.
/testfor
is not particularly useful, especially in multiplayer situations. You can replace it with a scoreboard operation that would account for multiple kills in the same tick, rather than assuming there is only 1 kill amongst all players.
Image example of the mechanism:
![Repeating Block (1) > Chain Block (2)](https://i.stack.imgur.com/S6fo8.png)
Commands:
Increment the fake "#pool" player's score equal to all playerscores for the "killedBasic" objective (or change "#pool" to a name you would prefer, removing "#" so that it appears on the sidebar).
/scoreboard players operation #pool money += @a[score_killedBasic_min=1] killedBasic
Set playerscores for "killedBasic" to 0 like usual.
/scoreboard players set @a[score_killedBasic_min=1] killedBasic 0
This is a multiplayer-friendly and multi-kill friendly solution that will not lock up if multiple kills are made in subsequent ticks.
Best Answer
This is a complicated system that you want to establish and requires the use of scoreboard objectives to function the way I think you want it to function. This is so that when a player reaches a certain level, in this case 1, they are given a health boost for as long as they are in that level. With any other effect this would be easily done but for the health boost you need to use a scoreboard objective system.
Step 1: Create An Objective
Step 2: Creating The Boost
These next commands need to be placed in a command block somewhere in the world set to repeat and Always Active for this to work at all times it is best if these are situated in the spawn chunks. If you don't know what these are or how to find them click here.
Step 3: Clearing The Effect
Now to get rid of that effect when the player no longer has the spesific levels required, these commands will also need to go into a command block somewhere in the world set to repeat and Always Active.
This should all work if I have done it right however I may have made a mistake so any feedback is appreciated.