###Performs once-per-day functions###
execute store result score $dayTime nitResourceTime run time query daytime
execute if entity @s[tag=nitHellSite] if score $dayTime nitResourceTime matches 12500 unless entity @e[tag=nitTyrantObjective,distance=..140] run function nitk:attacks/hell_attack
execute if entity @s[tag=nitTownPlanner] if score $dayTime nitResourceTime matches 6000 run function nitk:debug/restore_town_planner
execute if entity @s[tag=nitCitizen] if score $dayTime nitResourceTime matches 6000 run function nitk:recurs/kingdom_resources
execute if entity @s[tag=nitThrone] if score $dayTime nitResourceTime matches 6000 run function nitk:recurs/throne_effects
execute if entity @s[tag=nitResourceChest] if score $dayTime nitResourceTime matches 6000 run function nitk:recurs/chests_daily
execute if entity @s[tag=nitLibrarian] if score $dayTime nitResourceTime matches 6000 run function nitk:recurs/library_shuffle_loot
execute if entity @s[tag=nitFestival] if score $dayTime nitResourceTime matches 100 run function nitk:recurs/festival
execute if entity @s[tag=nitTownSquare] if score $dayTime nitResourceTime matches 120 run function nitk:recurs/town_square/visitor_check
execute if entity @s[tag=nitTownSquare,scores={nitResourceSpawn=1..}] if score $dayTime nitResourceTime matches 12500 run function nitk:recurs/town_square/visitor_check
execute if entity @s[tag=nitObservatory] if score $dayTime nitResourceTime matches 18000 if entity @a[tag=nitCitizen,distance=..12] run function nitk:recurs/observatory/spawn_meteor
execute if entity @s[tag=nitDenizen] if score $dayTime nitResourceTime matches 6000 run function nitco:recurs/fortress_resources
execute if entity @s[tag=nitBlazeReactor] if score $dayTime nitResourceTime matches 6000 run function nitco:recurs/blaze_resource
execute if entity @s[tag=nitEndizen] if score $dayTime nitResourceTime matches 6000 run function nitref:recurs/city_resources
execute if entity @s[tag=nitGApple] if score $dayTime nitResourceTime matches 6000 run function nitref:recurs/gold_apple_tree
execute if entity @s[tag=nitEndermollusk] if score $dayTime nitResourceTime matches 6000 run function nitref:recurs/oyster_pool
execute if entity @s[tag=nitPhantom] if score $dayTime nitResourceTime matches 6000 run function nitref:recurs/phantom_aviary

###Kills destroyed siteplanners###
execute if entity @s[tag=nitKSitePlanner] unless block ~ ~ ~ minecraft:dropper run function nitk:siteplanner_kill
execute if entity @s[tag=nitKWallPlanner] unless block ~ ~ ~ minecraft:dropper run function nitk:siteplanner_kill
execute if entity @s[tag=nitKCastlePlanner] unless block ~ ~ ~ minecraft:dropper run function nitk:siteplanner_kill
execute if entity @s[tag=nitKRailPlanner] unless block ~ ~ ~ minecraft:dropper run function nitk:siteplanner_kill
execute if entity @s[tag=nitCSitePlanner] unless block ~ ~ ~ minecraft:dropper run function nitk:siteplanner_kill
execute if entity @s[tag=nitCKeepPlanner] unless block ~ ~ ~ minecraft:dropper run function nitk:siteplanner_kill
execute if entity @s[tag=nitPortalPlanner] unless block ~ ~ ~ minecraft:dropper run function nitk:siteplanner_kill
execute if entity @s[tag=nitRSitePlanner] unless block ~ ~ ~ minecraft:dropper run function nitk:siteplanner_kill
execute if entity @s[tag=nitKBankPlanner] unless block ~ ~ ~ minecraft:dropper run function nitk:bankplanner_restore

###Performs functions for some town, fortress, and city structures###
execute if entity @s[tag=nitPowerElectricity] facing entity @e[tag=nitPowerElectricity,sort=furthest,limit=1] feet run function nitk:recurs/electricity_cosmetic
execute if entity @s[tag=nitRaid] run function nitk:recurs/town_square/raid_clock
execute if entity @s[tag=nitTimeAdd] run function nitk:recurs/stardial_add
execute if entity @s[tag=nitTimeSub] run function nitk:recurs/stardial_sub
execute if entity @s[tag=nitGateLever] run function nitk:recurs/gate_lever
execute if entity @s[tag=nitMeteor,tag=nitGenerated] run function nitk:recurs/observatory/meteor_particles
execute if entity @s[tag=nitMagicFarm] as @e[type=item,distance=..7,tag=!smithed.entity] run function nitco:recurs/magic_farm
execute if entity @s[tag=nitEndstoneGen] run function nitref:recurs/endstone_generator
execute if entity @s[tag=nitGCarrot] as @e[predicate=nitref:item_gcarrot,distance=..9,tag=!smithed.entity] run function nitref:recurs/gold_carrot_farm
execute if entity @s[tag=nitDragonCrystalAura] unless entity @e[tag=nitDragonCrystal,distance=..4] run function nitref:recurs/dragonology/crystal_aura

###Runs the special functions for some natural structures###
execute if entity @s[tag=nitAlignPuz] run function nitk:special/puzzleclock
execute if entity @s[tag=nitTyrantEntity,predicate=nitk:in_overworld] run function nitk:attacks/clock_attacks
execute if entity @s[tag=nitHellFactory] run function nitco:special/factory_wither
execute if entity @s[tag=nitBoxMarker,scores={nitBoxProg=..6}] unless block ~ ~ ~ minecraft:trapped_chest run function nitco:special/paradox_box/box_reset

###Alters the town planner and makes him sparkle, revealing new End recipes###
execute if entity @s[tag=nitKTP] run function nitref:planner_update

###Performs checks for the portal banners used during invasion###
execute if entity @s[tag=nitInvasionPortal] if entity @e[type=minecraft:arrow,distance=..1] run function nitref:invasion/portal_explode