############################################################
# Description: Villager Conversion
# Creator: CreeperMagnet_
############################################################

particle minecraft:happy_villager ~ ~ ~ 1 1 1 1 100 force
execute as @s[nbt={Profession:0},type=villager] run data merge entity @s {Tags:["tcc.entities.villager_upgrading.no_upgrade"],Profession:0,CustomName:"{\"translate\":\"tcc.entities.villager.artist\"}",Career:1,CareerLevel:42,Offers:{Recipes:[{buy:{id:"cocoa_beans",Count:10},maxUses:10,sell:{id:"emerald",Count:1}},{buy:{id:"blue_orchid",Count:5},maxUses:10,sell:{id:"emerald",Count:1}},{buy:{id:"lapis_lazuli",Count:8},maxUses:10,sell:{id:"emerald",Count:1}},{buy:{id:"cactus",Count:17},maxUses:10,sell:{id:"emerald",Count:1}},{buy:{id:"sunflower",Count:11},maxUses:10,sell:{id:"emerald",Count:1}},{buy:{id:"emerald",Count:4},maxUses:3,sell:{id:"painting",Count:1}},{buy:{id:"emerald",Count:3},maxUses:10,sell:{id:"dandelion_yellow",Count:1}},{buy:{id:"emerald",Count:3},maxUses:10,sell:{id:"rose_red",Count:1}},{buy:{id:"emerald",Count:3},maxUses:10,sell:{id:"pink_dye",Count:1}},{buy:{id:"emerald",Count:3},maxUses:10,sell:{id:"gray_dye",Count:1}},{buy:{id:"emerald",Count:3},maxUses:10,sell:{id:"ink_sac",Count:1}},{buy:{id:"emerald",Count:3},maxUses:10,sell:{id:"purple_dye",Count:1}},{buy:{id:"emerald",Count:3},maxUses:10,sell:{id:"bone_meal",Count:1}},{buy:{id:"emerald",Count:3},maxUses:10,sell:{id:"magenta_dye",Count:1}},{buy:{id:"emerald",Count:3},maxUses:10,sell:{id:"light_gray_dye",Count:1}},{buy:{id:"emerald",Count:3},maxUses:10,sell:{id:"orange_dye",Count:1}}]}}
execute as @s[nbt={Profession:3},type=villager] run data merge entity @s {Tags:["tcc.entities.villager_upgrading.no_upgrade"],CustomName:"{\"translate\":\"tcc.entities.villager.engineer\"}",CustomNameVisible:0,Career:1,CareerLevel:42,Profession:3,Offers:{Recipes:[{buy:{id:"comparator",Count:2},maxUses:20,sell:{id:"emerald",Count:1}},{buy:{id:"redstone_lamp",Count:3},maxUses:20,sell:{id:"emerald",Count:1}},{buy:{id:"daylight_detector",Count:2},maxUses:20,sell:{id:"emerald",Count:1}},{buy:{id:"emerald",Count:4},maxUses:10,sell:{id:"repeater",Count:1}},{buy:{id:"emerald",Count:3},maxUses:10,sell:{id:"redstone",Count:9}},{buy:{id:"emerald",Count:20},maxUses:2,sell:{id:"carrot_on_a_stick",Count:1,tag:{display:{Lore:["§7Durability: 200 / 200","§9§oThe Creeper's Code"],Name:"{\"translate\":\"tcc.items.wrench\",\"italic\":\"false\"}"},tcc:{Item:"wrench",Damage:0},Damage:5,Unbreakable:1b,HideFlags:4}}}]}}
execute as @s[nbt={Profession:1},type=villager] run data merge entity @s {Tags:["tcc.entities.villager_upgrading.no_upgrade"],CustomName:"{\"translate\":\"tcc.entities.villager.questmaker\"}",CustomNameVisible:0,Career:1,CareerLevel:42,Offers:{Recipes:[{buy:{id:"paper",Count:20},maxUses:20,sell:{id:"emerald",Count:1}},{buy:{id:"compass",Count:1},maxUses:20,sell:{id:"emerald",Count:1}},{buy:{id:"enchanted_book",Count:1},maxUses:20,sell:{id:"emerald",Count:3}},{buy:{id:"book",Count:1},buyB:{id:"iron_ingot",Count:2},maxUses:2,sell:{id:"carrot_on_a_stick",Count:1,tag:{tcc:{Item:"quest_book",Quest:"warrior"},Damage:7,Unbreakable:1b,display:{Name:"{\"translate\":\"tcc.items.quest_book\",\"italic\":\"false\"}",Lore:["§7Warrior's Quest"]},HideFlags:5}}},{buy:{id:"book",Count:1},buyB:{id:"potion",Count:1,tag:{Potion:"minecraft:poison"}},maxUses:2,sell:{id:"carrot_on_a_stick",Count:1,tag:{tcc:{Item:"quest_book",Quest:"rogue"},Damage:7,Unbreakable:1b,display:{Name:"{\"translate\":\"tcc.items.quest_book\",\"italic\":\"false\"}",Lore:["§7Rogue's Quest"]},HideFlags:5}}},{buy:{id:"book",Count:1},buyB:{id:"enchanted_book",Count:1},maxUses:2,sell:{id:"carrot_on_a_stick",Count:1,tag:{tcc:{Item:"quest_book",Quest:"mage"},Damage:7,Unbreakable:1b,display:{Name:"{\"translate\":\"tcc.items.quest_book\",\"italic\":\"false\"}",Lore:["§7Mage's Quest"]},HideFlags:5}}},{buy:{id:"book",Count:1},buyB:{id:"golden_apple",Count:1},maxUses:2,sell:{id:"carrot_on_a_stick",Count:1,tag:{tcc:{Item:"quest_book",Quest:"healer"},Damage:7,Unbreakable:1b,display:{Name:"{\"translate\":\"tcc.items.quest_book\",\"italic\":\"false\"}",Lore:["§7Healer's Quest"]},HideFlags:5}}},{buy:{id:"carrot_on_a_stick",Count:1,tag:{tcc:{Item:"quest_book_complete"},ench:[{id:1,lvl:1}],Damage:7,Unbreakable:1b,HideFlags:5,display:{Name:"{\"translate\":\"tcc.items.quest_book_complete\",\"italic\":\"false\"}"}}},maxUses:10,sell:{id:"emerald_block",Count:8}}]}}

# Charmer
execute as @s[tag=tcc.entities.villager_upgrading.hostile] run data merge entity @s {Silent:1b,DeathTime:19s,DeathLootTable:"minecraft:empty"}
execute as @s[tag=tcc.entities.villager_upgrading.hostile] run kill @s
execute as @s[type=illusion_illager] run summon villager ~ ~ ~ {Profession:0,Career:2}
execute as @s[type=vindication_illager] run summon villager ~ ~ ~ {Profession:5}
execute as @s[type=evocation_illager] run summon villager ~ ~ ~ {Profession:1,CustomName:"{\"translate\":\"tcc.entities.villager.redeemed_evoker\"}",CustomNameVisible:0}
execute as @s[type=witch] run summon villager ~ ~ ~ {Profession:2,CustomName:"{\"translate\":\"tcc.entities.villager.witch_doctor\"}",CustomNameVisible:0,Career:1,CareerLevel:42,Offers:{Recipes:[{buy:{id:"brewing_stand",Count:1},maxUses:10,sell:{id:"emerald",Count:5}},{buy:{id:"gunpowder",Count:10},maxUses:10,sell:{id:"emerald",Count:1}},{buy:{id:"glowstone_dust",Count:9},maxUses:10,sell:{id:"emerald",Count:1}},{buy:{id:"magma_cream",Count:5},maxUses:10,sell:{id:"emerald",Count:1}},{buy:{id:"emerald",Count:62},maxUses:10,sell:{id:"potion",Count:1,tag:{Potion:"minecraft:mundane",CustomPotionEffects:[{Id:3,Duration:6000,Amplifier:1}],display:{Name:"{\"translate\":\"tcc.items.haste_potion\",\"italic\":\"false\"}"}}}},{buy:{id:"emerald",Count:51},maxUses:10,sell:{id:"potion",Count:1,tag:{Potion:"minecraft:luck"}}},{buy:{id:"emerald",Count:41},maxUses:10,sell:{id:"potion",Count:1,tag:{Potion:"minecraft:mundane",display:{Name:"{\"translate\":\"item.minecraft.potion.effect.swiftness\",\"italic\":\"false\"}"},CustomPotionEffects:[{Id:1,Duration:3000,Amplifier:2}]}}}]},ArmorItems:[{},{},{},{id:"minecraft:carrot_on_a_stick",tag:{Unbreakable:1b,tcc:{Item:"witch_hat"},HideFlags:5,Damage:2s,display:{Name:"{\"translate\":\"tcc.items.witch_hat\",\"italic\":\"false\"}"}},Count:1b}],Tags:["tcc.entities.villager_upgrading.no_upgrade"]}