scoreboard players set @s nl.WriteDamage 0
scoreboard players operation @s nl.WriteDamage = @s nl.HealthCheck
scoreboard players operation @s nl.WriteDamage -= @s nl.Health

execute at @s unless entity @e[tag=nl_WriteDamage,distance=..1] run summon minecraft:armor_stand ~ ~ ~ {Small:1b,Invisible:1b,CustomNameVisible:1b,Tags:["nl_WriteDamage"],CustomName:'{"text":"0"}'}

execute at @s run summon minecraft:area_effect_cloud ~ 250 ~ {NoGravity:1,Tags:["nl_FindAir"]}
execute as @e[tag=nl_FindAir] at @s run function next_level:magic/find_air
tag @s add nl_WriteIndicator
execute as @s[scores={nl.WriteDamage=..-16}] at @e[tag=nl_FindAir] run setblock ~ ~-1 ~ minecraft:oak_sign{Text1:'[{"score":{"name":"@e[tag=nl_WriteIndicator,limit=1,sort=nearest]","objective":"nl.WriteDamage"},"color":"dark_red","italic":false}]'}
execute as @s[scores={nl.WriteDamage=-15..-11}] at @e[tag=nl_FindAir] run setblock ~ ~-1 ~ minecraft:oak_sign{Text1:'[{"score":{"name":"@e[tag=nl_WriteIndicator,limit=1,sort=nearest]","objective":"nl.WriteDamage"},"color":"red","italic":false}]'}
execute as @s[scores={nl.WriteDamage=-10..-7}] at @e[tag=nl_FindAir] run setblock ~ ~-1 ~ minecraft:oak_sign{Text1:'[{"score":{"name":"@e[tag=nl_WriteIndicator,limit=1,sort=nearest]","objective":"nl.WriteDamage"},"color":"gold","italic":false}]'}
execute as @s[scores={nl.WriteDamage=-6..-4}] at @e[tag=nl_FindAir] run setblock ~ ~-1 ~ minecraft:oak_sign{Text1:'[{"score":{"name":"@e[tag=nl_WriteIndicator,limit=1,sort=nearest]","objective":"nl.WriteDamage"},"color":"yellow","italic":false}]'}
execute as @s[scores={nl.WriteDamage=-3..-2}] at @e[tag=nl_FindAir] run setblock ~ ~-1 ~ minecraft:oak_sign{Text1:'[{"score":{"name":"@e[tag=nl_WriteIndicator,limit=1,sort=nearest]","objective":"nl.WriteDamage"},"color":"gray","italic":false}]'}
execute as @s[scores={nl.WriteDamage=-1..0}] at @e[tag=nl_FindAir] run setblock ~ ~-1 ~ minecraft:oak_sign{Text1:'[{"score":{"name":"@e[tag=nl_WriteIndicator,limit=1,sort=nearest]","objective":"nl.WriteDamage"},"color":"white","italic":false}]'}
execute as @s[scores={nl.WriteDamage=1..4}] at @e[tag=nl_FindAir] run setblock ~ ~-1 ~ minecraft:oak_sign{Text1:'[{"score":{"name":"@e[tag=nl_WriteIndicator,limit=1,sort=nearest]","objective":"nl.WriteDamage"},"color":"green","italic":false}]'}
execute as @s[scores={nl.WriteDamage=5..}] at @e[tag=nl_FindAir] run setblock ~ ~-1 ~ minecraft:oak_sign{Text1:'[{"score":{"name":"@e[tag=nl_WriteIndicator,limit=1,sort=nearest]","objective":"nl.WriteDamage"},"color":"dark_green","italic":false}]'}
tag @s remove nl_WriteIndicator

execute at @s as @e[tag=nl_WriteDamage,limit=1,sort=nearest] at @e[tag=nl_FindAir] run data modify entity @s CustomName set from block ~ ~-1 ~ Text1
scoreboard players operation @s nl.Health = @s nl.HealthCheck

execute at @e[tag=nl_FindAir] run setblock ~ ~-1 ~ air
kill @e[tag=nl_FindAir]

