tag @s add SoulGemAct
execute as @a[tag=K,tag=SoulGemAct,nbt={Inventory:[{tag:{kyujunkstash:69b,kyugem:1b}}]}] run execute if predicate suhc:75percent run tag @s add GivePageForGem
execute as @a[tag=K,tag=SoulGemAct,tag=!GivePageForGem,nbt={Inventory:[{tag:{kyujunkstash:69b,kyugem:1b}}]}] run tag @s add GiveWitchForGem
execute as @a[tag=K,tag=SoulGemAct,tag=GivePageForGem,nbt={Inventory:[{tag:{kyujunkstash:69b,kyugem:1b}}]}] run execute at @s run loot spawn ~ ~ ~ loot minecraft:shared_loot_tablejustpages
execute as @a[tag=K,tag=SoulGemAct,tag=GivePageForGem,nbt={Inventory:[{tag:{kyujunkstash:69b,kyugem:1b}}]}] run execute at @s run playsound minecraft:block.enchantment_table.use ambient @p ~ ~ ~ 1 2 1
execute as @a[tag=K,tag=SoulGemAct,tag=GivePageForGem,nbt={Inventory:[{tag:{kyujunkstash:69b,kyugem:1b}}]}] run clear @s diamond{kyujunkstash:69b,kyugem:1b} 1
execute as @a[tag=K,tag=SoulGemAct,tag=GivePageForGem,nbt={Inventory:[{tag:{kyujunkstash:69b,kyugem:1b}}]}] run tellraw @s ["",{"text":"Your soul gem disappears, and a spell page appears in its place.","color":"blue"},{"text":"","color":"red"}]
execute as @a[tag=K,tag=SoulGemAct,tag=!GivePageForGem,tag=GiveWitchForGem,nbt={Inventory:[{tag:{kyujunkstash:69b,kyugem:1b}}]}] run execute at @s run summon witch ~ ~ ~
execute as @a[tag=K,tag=SoulGemAct,tag=!GivePageForGem,tag=GiveWitchForGem,nbt={Inventory:[{tag:{kyujunkstash:69b,kyugem:1b}}]}] run execute at @s run playsound minecraft:entity.witch.ambient ambient @p ~ ~ ~ 1 1.4 1
execute as @a[tag=K,tag=SoulGemAct,tag=!GivePageForGem,tag=GiveWitchForGem,nbt={Inventory:[{tag:{kyujunkstash:69b,kyugem:1b}}]}] run clear @s diamond{kyujunkstash:69b,kyugem:1b} 1
execute as @a[tag=K,tag=SoulGemAct,tag=!GivePageForGem,tag=GiveWitchForGem,nbt={Inventory:[{tag:{kyujunkstash:69b,kyugem:1b}}]}] run tellraw @s ["",{"text":"Your soul gem vanishes, and spawns a witch in the process!","color":"blue"},{"text":"","color":"red"}]
tag @a remove SoulGemAct
tag @a remove GivePageForGem
tag @a remove GiveWitchForGem