#say tick 

# Check Mob health #
execute at @a as @e[limit=1,tag=!nl_setup_indicator,distance=..32,sort=nearest,type=#next_level:all_mobs] run function next_level:damage_indicator/init
execute at @a as @e[tag=nl_setup_indicator,distance=..16] run function next_level:damage_indicator/check_health

# Show Damage indicator #
scoreboard players add @e[tag=nl_WriteDamage] nl.Timer 1
execute as @e[tag=nl_WriteDamage,scores={nl.Timer=..10}] at @s run tp ~ ~.1 ~
kill @e[tag=nl_WriteDamage,scores={nl.Timer=20..}] 

# Well Rested Bonus # 
execute as @a[scores={nl.WellRested=1..}] unless entity @s[tag=nl_Rested] at @s run function next_level:rested_bonus 
scoreboard players remove @a[scores={nl.RestTimer=2..}] nl.RestTimer 1 
tag @a[scores={nl.RestTimer=1}] remove nl_Rested 
scoreboard players set @a[scores={nl.RestTimer=1}] nl.RestTimer 0 

# Show Mana Bar # 
execute as @a[nbt={SelectedItem:{tag:{nl_ShowMana:1b}}}] run function next_level:magic/show_mana

# Magic Staff Triggers # 
execute as @a[scores={nl.Staff.Trigger=1..}] at @s run function next_level:magic/staffs/main
execute as @e[tag=nl_Staff.Restore] run function next_level:magic/staffs/ethereal/restore
execute as @e[tag=nl_Staff.Freeze] run function next_level:magic/staffs/frozen/freeze
execute as @e[tag=nl_Staff.Entangle] run function next_level:magic/staffs/cactus/entangle

# Global # 
execute if score #Global nl.Timer matches 20.. run function next_level:schedule
scoreboard players add #Global nl.Timer 1 

# Custom Enchantments: Global tick function #
function next_level:custom_enchantments/tick

# Custom Blocks: Global tick function #
execute as @a run function next_level:custom_blocks/global

# Custom Sets: Global tick function #
function next_level:custom_sets/global

# Health Pool: Global tick function # 
execute as @e[tag=nl_HealthPool] at @s run function next_level:health_pool/global

# Tag hit entitiy # 
execute as @a[scores={nl.DetectDamage=1..}] run function next_level:combat/tag_entity

# Custom Status Effects #
execute as @e[scores={nl.DMG.Timer=1..}] run scoreboard players remove @s nl.DMG.Timer 1
execute as @e[tag=nl_Hit_by_Player,scores={nl.DetectEntity=1..}] store result score @s nl.DetectEntity run data get entity @s HurtTime

    # Bleed #
execute at @e[scores={nl.DMG.Bleed=1..}] run particle minecraft:damage_indicator ~ ~1 ~ 0.3 0.3 0.3 0 1
execute as @e[scores={nl.DMG.Bleed=1..}] run effect give @s minecraft:wither 2 0 true
execute as @e[scores={nl.DMG.Bleed=1..}] run scoreboard players remove @s nl.DMG.Bleed 1

    # Stun  #
execute at @e[scores={nl.DMG.Stun=1..}] run particle minecraft:crit ~ ~1.5 ~ 0.3 0.3 0.3 0 1
execute as @e[scores={nl.DMG.Stun=1..}] run effect give @s minecraft:slowness 2 255 true
execute as @e[scores={nl.DMG.Stun=1..}] run scoreboard players remove @s nl.DMG.Stun 1
    
    # Infect #
execute at @e[scores={nl.DMG.Infect=1..}] run particle minecraft:dust 0 1 0 1 ~ ~1 ~ 0.3 0.3 0.3 0 1
execute as @e[scores={nl.DMG.Infect=1..}] run effect give @s minecraft:wither 2 0 true
execute as @e[scores={nl.DMG.Infect=1..}] run scoreboard players remove @s nl.DMG.Infect 1

    # Leech Life #
execute as @a[nbt={SelectedItem:{tag:{nl_Enchant_LeechLife:1b}}}] at @s as @e[distance=..8,scores={nl.DMG.Leech=1..}] run effect give @s minecraft:wither 2 0 true
execute as @a[nbt={SelectedItem:{tag:{nl_Enchant_LeechLife:1b}}}] at @s as @e[distance=..8,scores={nl.DMG.Leech=1..}] run particle minecraft:dust 1 0 0 1 ~ ~1 ~ 1 1 1 0 10
execute as @e[scores={nl.DMG.Leech=1..}] at @s as @a[nbt={SelectedItem:{tag:{nl_Enchant_LeechLife:1b}}}] unless entity @s[nbt={ActiveEffects:[{Id:10b}]}] run effect give @s minecraft:regeneration 2 0 false
execute as @e[scores={nl.DMG.Leech=1..}] run scoreboard players remove @s nl.DMG.Leech 1

# Check for holding Magic Clock #
execute as @a[nbt={SelectedItem:{tag:{nl_ItemID:135b}}}] at @s run function next_level:clock/main
execute as @a[nbt={Inventory:[{Slot:-106b,tag:{nl_ItemID:135b}}]}] at @s run function next_level:clock/main

# Evil Fairy (vex) Particles #  
execute as @e[type=minecraft:vex,tag=nl_Particle.Purple] at @s run particle minecraft:dragon_breath ~ ~ ~ .1 .1 .1 0 

# Mana Potion # 
execute as @a[nbt={ActiveEffects:[{Id:27b}]}] run function next_level:resting_herbs