How to effect players that triggered a command in Minecraft?
First, add an objective to track if a player is burning:
/scoreboard objectives add isBurning dummy
On a clock, run the following commands in this order:
/scoreboard players set @a isBurning 1
/scoreboard players set @a isBurning 0 {Fire:-20s}
/effect @a[score_isBurning_min=1] instant_health 20 20
The way this works is that, first, everybody's isBurning
score is set to 1. When not burning, a player's Fire
tag is at -20s
, so the isBurning
score for those with a Fire
tag at -20s
is then set to 0, leaving only those who are burning still with an isBurning
score of 1. The instant_health potion effect can then be applied to the players that are burning.
As a general tip, the /testfor
command is a lot less useful than people seem to think. When using /testfor
, you are essentially just asking "Does this entity exist?" and getting a yes/no answer without being able to do anything with the entity matched your query. If you want to be doing something with the entity (healing, killing, teleporting, etc.), you shouldn't use /testfor
.