I would like to test for entities in a certain area and number them.
A target selector always returns a list of selected entities in the order of the
For example, the following target selector will return a list of players within 100 blocks of the running command block, in random order:
I would like to be able to number the entities returned by the target selector in two ways: through scoreboard objectives, and through scoreboard tags. For example, if the target selector returns players
Alice, Joe, Bob, I would like for
Alice to get scoreboard value 1,
Joe to get 2, and
Bob to get 3. If it returns players
Joe, Alice, Bob,
Joe would get 1,
Alice would get 2, and
Bob would get 3.
Using scoreboard tags, a tag named
Player1 would be added to the first player,
Player2 for the 2nd, and so on.
What is the best way to construct a functioning command mechanism for this purpose? Note, I would like an answer for all 3 non-arbitrary sorting methods, meaning
[distance=..100] as your target selector template argument so that everyone's answer is consistent in what part is their target selector.