How can I add half a heart of health using command blocks?

How can I add half a heart of health using command blocks? - Books On The Table

How would I add half a heart of health to a player when they are in a certain area?

I have got the detection part right I just don't know how to add exactly half a heart. Here is what I have tried so far:

/execute @p ~ ~ ~ detect ~ ~-1 ~ grass 0 effect @p 6

This heals the player too much though.



Best Answer

You can't add a half hearth via instant health, however you could using regeneration for 3 seconds with level 1.

/effect @p minecraft:regeneration 3 0

This gives the player one half heart. For every 2,5 seconds the player gets half a heart.




Pictures about "How can I add half a heart of health using command blocks?"

How can I add half a heart of health using command blocks? - Unrecognizable female sitting with bare legs on white sheet with small red heart in hands in light room in daytime
How can I add half a heart of health using command blocks? - Thank You! Heart Text
How can I add half a heart of health using command blocks? - Three Beige, Yellow, and Pink Heart Marshmallows



What is the command to get half a heart 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




More answers regarding how can I add half a heart of health using command blocks?

Answer 2

Method A: For all users to use

To heal a player with this method exactly half a heart, set the score "Heal" on the player to 10. (Setting this on a loop will permanently give them regeneration until they disable the loop)

Commands in Chat

/scoreboard objectives add Heal dummy

Inside Command Blocks

(Note: All command blocks must be in line) Repeating Command Block (Always Active, Unconditional)

scoreboard players remove @a[scores={Heal=0..}] Heal 1
Chain Command Blocks (Always Active, Unconditional)
execute as @a[scores={Heal=9}] run effect give @s regeneration 1 2 true
effect clear @a[scores={Heal=0}] regeneration

Recommended Commands In Chat

/gamerule commandBlockOutput false

Method B: For this specific example

To heal a player with this method exactly half a heart, stand on a Grass Block. Note if they stand off the Grass Block before they heal, they stop healing.

Commands in Chat

/scoreboard objectives add Heal dummy
/scoreboard objectives add HealAllow dummy

Inside Command Blocks

(Note: All command blocks must be in line) Repeating Command Block (Always Active, Unconditional)

execute as @a if block ~ ~-1 ~ grass_block run scoreboard players set @s HealAllow 1

Chain Command Blocks (Always Active, Unconditional)

scoreboard players set @a[scores={HealAllow=1}] Heal 10
scoreboard players set @a[scores={HealAllow=1}] HealAllow 2
execute as @a[scores={HealAllow=2}] unless block ~ ~-1 ~ grass_block run scoreboard players set @s Heal 1
execute as @a[scores={HealAllow=2}] unless block ~ ~-1 ~ grass_block run scoreboard players reset @s HealAllow
scoreboard players remove @a[scores={Heal=0..}] Heal 1
execute as @a[scores={Heal=9}] run effect give @s regeneration 1 2 true
effect clear @a[scores={Heal=0}] regeneration
scoreboard players set @a[scores={Heal=0}] HealAllow 1

Recommended Commands In Chat

/gamerule commandBlockOutput false

In Method B, if you wish to make them have to jump off the block to heal again, delete the last chain command block.

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

Images: Ylanite Koppens, Puwadon Sang-ngern, Řaj Vaishnaw, Ylanite Koppens