0

I have a command that simply turns grass into dirt when a player stands on it.

execute @p ~ ~ ~ detect ~ ~-1 ~ grass 0 setblock ~ ~-1 ~ dirt

Is there any way to make this not happen when the player's health is full? (It may not involve any comparators, only command blocks as I am using a single command block generator, therefore it will come with a constant clock as well.)

5

First, make a scoreboard objective that tracks the player's health:

Create the objective (run only once):

/scoreboard objectives add Health health

Then you run the execute command as following:

/execute @a[score_Health_min=0,score_Health=19] ~ ~ ~ detect ~ ~-1 ~ grass 0 setblock ~ ~-1 ~ dirt

How this works is that it runs the command for all players with a maximum Health score of 19.

| improve this answer | |
  • 1.13 syntax: /execute positioned as @a[scores={Health=0..19}] if block ~ ~-1 ~ grass run setblock ~ ~-1 ~ dirt – pppery Jul 10 '19 at 2:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.