Arqade Asked by McArthur Alford on June 13, 2021
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.
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.
Answered by nelson2tm on June 13, 2021
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)
/scoreboard objectives add Heal dummy
(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
/gamerule commandBlockOutput false
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.
/scoreboard objectives add Heal dummy
/scoreboard objectives add HealAllow dummy
(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
/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.
Answered by Blank on June 13, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP