place template nitref:city/dragonologist ~-7 ~ ~-8
setblock ~ 255 ~-1 minecraft:barrier

###Places the siteplanner on top###
place template nitref:siteplanner ~ ~8 ~

advancement grant @a[distance=..20] only nitref:nitref/ach3.3 build-dragonologist
tag @a[distance=..10] add nitDragonologyBuilt
tellraw @a[tag=nitDragonologyBuilt,distance=..10] [{"text":"[۩]","color":"green","bold":true},{"text":": ","color":"white","bold":false},{"text":"You can now participate in Dragonology Research! Talk to the Dragonologist to learn how to collect Dragon Scales!","color":"white","bold":false}]

###Summons Dragonologist
execute as @e[tag=nitRD,limit=1,sort=nearest] at @s run summon villager ~ ~ ~ {Xp:150,VillagerData:{profession:cartographer,level:4,type:snow},Invulnerable:1,PersistenceRequired:1,Silent:1,NoAI:1,CustomName:'{"text":"Dragonologist"}',ActiveEffects:[{Id:14,Amplifier:0,Duration:999999,ShowParticles:0b}],Offers:{Recipes:[{buy:{id:feather,Count:1},sell:{id:written_book,Count:1},rewardExp:0b,maxUses:9999999},{buy:{id:flint,Count:4,tag:{display:{Name:'{"text":"Dragon Scale","color":"aqua","italic":false}'},nitref_dragonScale:1b}},sell:{id:knowledge_book,Count:1,tag:{display:{Name:'{"text":"Dragon Research","color":"dark_purple","italic":false}'},nitref_dragonResearch:1b}},rewardExp:0b,maxUses:9999999},{buy:{id:flint,Count:9,tag:{display:{Name:'{"text":"Dragon Scale","color":"aqua","italic":false}'},nitref_dragonScale:1b}},sell:{id:knowledge_book,Count:1,tag:{display:{Name:'{"text":"Dragon Research","color":"dark_purple","italic":false}'},nitref_dragonResearch:1b}},rewardExp:0b,maxUses:9999999}]},Tags:[nitEndizen,nitEntity,nitDragonologist,smithed.entity,smithed.strict]}
scoreboard players operation @e[tag=nitRCP,limit=1,sort=nearest] nitID = @s nitID
execute as @e[tag=nitDragonologist,limit=1,sort=nearest] at @s run summon enderman ~ ~ ~ {CustomName:'{"text":"Dragonologist"}',Invulnerable:1b,NoAI:1b,PersistenceRequired:1b,Tags:[nitDragonologistE,smithed.entity,smithed.strict]}
execute as @e[tag=nitDragonologist,limit=1,sort=nearest] at @s run tp @e[tag=nitDragonologistE,limit=1,sort=nearest] @s
effect give @e[tag=nitDragonologist,limit=1,sort=nearest] minecraft:invisibility 999999 0 true
tag @a[distance=..30] add nitDragonologyBuilt
function nitk:debug/update_all
kill @e[tag=nitRD,limit=1,sort=nearest]

function nitref:siteplanner/cleanup