#summon a bunch of markers, to be spread out
summon marker ~ ~ ~ {Tags:["BlackCorruptSpawn2"]}
summon marker ~ ~ ~ {Tags:["BlackCorruptSpawn2"]}
summon marker ~ ~ ~ {Tags:["BlackCorruptSpawn2"]}
summon marker ~ ~ ~ {Tags:["BlackCorruptSpawn2"]}
summon marker ~ ~ ~ {Tags:["BlackCorruptSpawn2"]}
summon marker ~ ~ ~ {Tags:["BlackCorruptSpawn2"]}
summon marker ~ ~ ~ {Tags:["BlackCorruptSpawn2"]}

#spread the markers
execute at @s run execute as @e[type=marker,distance=..1,tag=BlackCorruptSpawn2] run function zzzzdonotuse:mobspawners/spawnerstuff/blackcorruptspreadcoord


#summon a marker, and generate a number between 0-9 to determine how many markers(from above) will spawn mobs, up to 3
summon marker ~ ~ ~ {Tags:["BlackCorrSpawnNum"]}
execute at @s run execute store result score @s KyuDummy run data get entity @e[type=marker,distance=..1,tag=BlackCorruptSpawnNum,limit=1,sort=nearest] UUID[0] .1
scoreboard players set @s KyuDummy2 9
scoreboard players operation @s KyuDummy %= @s KyuDummy2

#60% chance to spawn 1 mob, 30% chance to spawn 2 mobs, 10% chance to spawn 3 mobs
execute at @s[scores={KyuDummy=0..5}] run tag @e[type=marker,distance=..10,tag=BlackCorruptSpawn2,limit=1,sort=random] add DoASpawn
execute at @s[scores={KyuDummy=6..8}] run tag @e[type=marker,distance=..10,tag=BlackCorruptSpawn2,limit=2,sort=random] add DoASpawn
execute at @s[scores={KyuDummy=9}] run tag @e[type=marker,distance=..10,tag=BlackCorruptSpawn2,limit=3,sort=random] add DoASpawn
execute at @s run kill @e[type=marker,distance=..1,sort=nearest,tag=BlackCorrSpawnNum]


##I *would* have spread this out into another function, but eh

#generate random number(based on marker's UUID) between 0-21 to determine the mob spawn
execute at @s run execute as @e[type=marker,distance=..10,tag=BlackCorruptSpawn2,tag=DoASpawn] run execute at @s run execute store result score @s KyuDummy run data get entity @s UUID[0] .1
execute at @s run execute as @e[type=marker,distance=..10,tag=BlackCorruptSpawn2,tag=DoASpawn] run scoreboard players set @s KyuDummy2 22
execute at @s run execute as @e[type=marker,distance=..10,tag=BlackCorruptSpawn2,tag=DoASpawn] run scoreboard players operation @s KyuDummy %= @s KyuDummy2

execute at @s run execute as @e[type=marker,distance=..10,tag=BlackCorruptSpawn2,tag=DoASpawn] run execute at @s[scores={KyuDummy=0..15}] run summon wither_skeleton ~ ~ ~ {Tags:["GKNameTag"],HandItems:[{id:"minecraft:stone_sword",Count:1b},{}],ArmorItems:[{id:"minecraft:leather_boots",Count:1b,tag:{display:{color:3873306}}},{id:"minecraft:leather_leggings",Count:1b,tag:{display:{color:3873306}}},{id:"minecraft:leather_chestplate",Count:1b,tag:{display:{color:3873306}}},{id:"minecraft:leather_helmet",Count:1b,tag:{display:{color:3873306}}}],Attributes:[{Name:generic.armor,Base:5}]}
execute at @s run execute as @e[type=marker,distance=..10,tag=BlackCorruptSpawn2,tag=DoASpawn] run execute at @s[scores={KyuDummy=16..18}] run summon wither_skeleton ~ ~ ~ {Tags:["GKNameTag"],HandItems:[{id:"minecraft:bow",Count:1b,tag:{Enchantments:[{id:"minecraft:punch",lvl:1s}]}},{id:"minecraft:tipped_arrow",Count:1b,tag:{CustomPotionEffects:[{Id:15b,Amplifier:0b,Duration:200},{Id:20b,Amplifier:0b,Duration:100}],CustomPotionColor:3146756}}],ArmorItems:[{id:"minecraft:leather_boots",Count:1b,tag:{display:{color:3873306}}},{id:"minecraft:leather_leggings",Count:1b,tag:{display:{color:3873306}}},{id:"minecraft:leather_chestplate",Count:1b,tag:{display:{color:3873306}}},{id:"minecraft:leather_helmet",Count:1b,tag:{display:{color:3873306}}}],Attributes:[{Name:generic.armor,Base:5}]}
execute at @s run execute as @e[type=marker,distance=..10,tag=BlackCorruptSpawn2,tag=DoASpawn] run execute at @s[scores={KyuDummy=19..21}] run summon enderman ~ ~ ~
execute at @s run execute as @e[type=marker,distance=..10,tag=BlackCorruptSpawn2,tag=DoASpawn] run execute at @s run particle large_smoke ~ ~1 ~ 0.2 0.5 0.2 0.07 15 normal
execute at @s run execute as @e[type=marker,distance=..10,tag=BlackCorruptSpawn2,tag=DoASpawn] run execute at @s run playsound minecraft:entity.wither_skeleton.ambient hostile @a[distance=..7] ~ ~ ~ 1 0.85
execute at @s run execute as @e[type=marker,distance=..10,tag=BlackCorruptSpawn2] run kill @s

