how to not commence a command depending on player health? [duplicate]

how to not commence a command depending on player health? [duplicate] - From below of crop multiethnic team of professional basketball players gathering and putting hands together while standing on playground before game

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.)



Best Answer

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.




Pictures about "how to not commence a command depending on player health? [duplicate]"

how to not commence a command depending on player health? [duplicate] - Person Playing Tennis
how to not commence a command depending on player health? [duplicate] - From below of concentrated basketball player with tattoos on arms preparing throwing ball to hoop
how to not commence a command depending on player health? [duplicate] - Free stock photo of adult, basketball, basketball player



How do you turn off repeat commands in Minecraft?

To set the health of a player, set that player's sethealth scoreboard to what health you want that player to have, then run the function editor:set_health as the player you want to edit health and you are done.



How To Change A Player's Health With Command Blocks




Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Andrea Piacquadio, Isabella Mendes, Andrea Piacquadio, Kampus Production