execute store result score world ShrineRoll run random value 1..100

playsound minecraft:entity.arrow.hit_player master @a 0 1 0 10000 0.7
tellraw @a [{"color":"dark_purple","obfuscated":true,"text":"xx"},{"bold":false,"color":"light_purple","obfuscated":false,"text":" A shrine has spawned near the center! "},{"color":"dark_purple","obfuscated":true,"text":"xx"}]

execute if score world ShrineRoll matches 1..20 run function kiwi:enchantment_shrines/protection/shrine_of_protection_spawn
execute unless entity @a[scores={limitbreak_chosen_class=3}] if score world ShrineRoll matches 21..40 run function kiwi:enchantment_shrines/sharpness/shrine_of_sharpness_spawn
execute unless entity @a[scores={limitbreak_chosen_class=3}] if score world ShrineRoll matches 41..45 run function kiwi:enchantment_shrines/power/shrine_of_power_spawn
execute if score world ShrineRoll matches 46..65 run function kiwi:enchantment_shrines/unbreaking/shrine_of_unbreaking_spawn
execute if score world ShrineRoll matches 66..75 run function kiwi:enchantment_shrines/growth/shrine_of_growth_spawn
execute if score world ShrineRoll matches 76..85 run function kiwi:enchantment_shrines/mending/shrine_of_mending_spawn
execute if score world ShrineRoll matches 86..95 run function kiwi:enchantment_shrines/thorns/shrine_of_thorns_spawn
execute if score world ShrineRoll matches 96..100 run function kiwi:enchantment_shrines/feather_falling/shrine_of_feather_falling_spawn

# If there's a player with [HUNTER] class
execute if entity @a[scores={limitbreak_chosen_class=3}] if score world ShrineRoll matches 21..30 run function kiwi:enchantment_shrines/sharpness/shrine_of_sharpness_spawn
execute if entity @a[scores={limitbreak_chosen_class=3}] if score world ShrineRoll matches 31..40 run function kiwi:enchantment_shrines/power/shrine_of_power_spawn

# 20% chance to spawn an additional shrine
execute store result score world ShrineRoll run random value 1..5
execute if score world ShrineRoll matches 1 run function kiwi:enchantment_shrines/shrine_roll_spawn

execute in kiwi2:limitbreak_run_dimension run spreadplayers 0 0 8 20 false @e[tag=enchantment_shrine]