###Kills the old resource deposits from the matching town###
scoreboard players operation #nitID nitTemp = @e[tag=nitKTP,limit=1,sort=nearest] nitID
execute as @e[tag=nitLumberStor,distance=..150] if score @s nitID = #nitID nitTemp run tag @s add nitID_match
execute as @e[tag=nitStoneStor,distance=..150] if score @s nitID = #nitID nitTemp run tag @s add nitID_match
kill @e[tag=nitLumberStor,tag=nitID_match,limit=1,sort=nearest,distance=..150]
kill @e[tag=nitStoneStor,tag=nitID_match,limit=1,sort=nearest,distance=..150]

execute if entity @s[tag=nitSiteEast] run place template nitk:town/silo ~1 ~-3 ~-7

execute if entity @s[tag=nitSiteWest] run place template nitk:town/silo ~-1 ~-3 ~7 180

execute if entity @s[tag=nitSiteNorth] run place template nitk:town/silo ~-7 ~-3 ~-1 counterclockwise_90

execute if entity @s[tag=nitSiteSouth] run place template nitk:town/silo ~7 ~-3 ~1 clockwise_90

function nitk:siteplanner/new_sites_check
function nitk:siteplanner/attacks_check
advancement grant @a[distance=..20] only nitk:nitk/complete_town build-silo

scoreboard players operation @e[tag=nitLumberStor,limit=1,sort=nearest] nitID = @e[tag=nitKTP,limit=1,sort=nearest] nitID
scoreboard players operation @e[tag=nitStoneStor,limit=1,sort=nearest] nitID = @e[tag=nitKTP,limit=1,sort=nearest] nitID
scoreboard players operation #nitID nitTemp = @e[tag=nitKTP,limit=1,sort=nearest] nitID
execute as @e[tag=nitLumberer] if score @s nitID = #nitID nitTemp run tag @s add nitID_match
execute as @e[tag=nitMiner] if score @s nitID = #nitID nitTemp run tag @s add nitID_match
tag @e[tag=nitMiner,type=villager,tag=nitID_match] add nitAtSilo
tag @e[tag=nitLumberer,type=villager,tag=nitID_match] add nitAtSilo
tag @e[tag=nitLumberer,tag=nitID_match] remove nitID_match
tag @e[tag=nitMiner,tag=nitID_match] remove nitID_match