execute at @s as @e[nbt={HurtTime:10s},limit=1,sort=nearest,tag=!ignorethorns] run tag @s add maxhpdown
execute at @e[tag=maxhpdown] run playsound minecraft:block.beacon.power_select player @a ~ ~1 ~ .4 2

execute as @e[tag=maxhpdown] store result score @s maxhp run attribute @s max_health get
execute as @e[tag=maxhpdown] run scoreboard players remove @s maxhp 4
execute as @e[tag=maxhpdown] store result entity @s attributes.[{id:"minecraft:max_health"}].base int 1 run scoreboard players get @s maxhp
execute as @e[tag=maxhpdown] run scoreboard players reset @s maxhp
tag @e remove maxhpdown