#count nearby mob spawns
scoreboard players set @s KyuDummy3 0
scoreboard players set @s[tag=SilverfishSpawner] KyuDummy3 -15

#cactus trap spawner
scoreboard players set @s[tag=SpawnerNum9] KyuDummy3 1

execute as @s[tag=SkeletonSpawner] run execute at @e[distance=..9,type=skeleton] run scoreboard players add @s KyuDummy3 1
execute as @s[tag=SkeletonSpawnerDoubleWeight] run execute at @e[distance=..9,type=skeleton] run scoreboard players add @s KyuDummy3 1
execute as @s[tag=ZombieSpawner] run execute at @e[distance=..9,type=husk] run scoreboard players add @s KyuDummy3 1
execute as @s[tag=BlazeSpawner] run execute at @e[distance=..20,type=blaze] run scoreboard players add @s KyuDummy3 1
execute as @s[tag=CaveSpiderSpawner] run execute at @e[distance=..9,type=cave_spider] run scoreboard players add @s KyuDummy3 1
execute as @s[tag=SilverfishSpawner] run execute at @e[distance=..9,type=silverfish] run scoreboard players add @s KyuDummy3 1

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

execute as @s[tag=SkeletonSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","SkeletonMarker"]}
execute as @s[tag=ZombieSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","ZombieMarker"]}
execute as @s[tag=BlazeSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","BlazeMarker"]}
execute as @s[tag=CaveSpiderSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","CaveSpiderMarker"]}
execute as @s[tag=SkeletonSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","SkeletonMarker"]}
execute as @s[tag=ZombieSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","ZombieMarker"]}
execute as @s[tag=BlazeSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","BlazeMarker"]}
execute as @s[tag=CaveSpiderSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","CaveSpiderMarker"]}
execute as @s[tag=SkeletonSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","SkeletonMarker"]}
execute as @s[tag=ZombieSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","ZombieMarker"]}
execute as @s[tag=BlazeSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","BlazeMarker"]}
execute as @s[tag=CaveSpiderSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","CaveSpiderMarker"]}
execute as @s[tag=SkeletonSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","SkeletonMarker"]}
execute as @s[tag=ZombieSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","ZombieMarker"]}
execute as @s[tag=BlazeSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","BlazeMarker"]}
execute as @s[tag=CaveSpiderSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","CaveSpiderMarker"]}
execute as @s[tag=SkeletonSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","SkeletonMarker"]}
execute as @s[tag=ZombieSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","ZombieMarker"]}
execute as @s[tag=BlazeSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","BlazeMarker"]}
execute as @s[tag=CaveSpiderSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","CaveSpiderMarker"]}
execute as @s[tag=SkeletonSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","SkeletonMarker"]}
execute as @s[tag=ZombieSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","ZombieMarker"]}
execute as @s[tag=BlazeSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","BlazeMarker"]}
execute as @s[tag=CaveSpiderSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","CaveSpiderMarker"]}
execute as @s[tag=SilverfishSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","SilverfishMarker"]}
execute as @s[tag=SilverfishSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","SilverfishMarker"]}
execute as @s[tag=SilverfishSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","SilverfishMarker"]}
execute as @s[tag=SilverfishSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","SilverfishMarker"]}
execute as @s[tag=SilverfishSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","SilverfishMarker"]}
execute as @s[tag=SilverfishSpawner] run summon marker ~ ~ ~ {Tags:["PyramidSpawn2","SilverfishMarker"]}

#3Range
#4Range
#5Range
#6Range
#6SquareRange
#7Range
#9Range

#-7ZRangeOffset
#-2ZRangeOffset
#-5Z_8X_RangeOffset
#-2Z_2X_RangeOffset
#2Z_2X_RangeOffset
#-1Z_-1X_RangeOffset
#-2Z_-1X_RangeOffset
#1Z_1X_RangeOffset
#3Z_0X_RangeOffset
#4Z_1X_RangeOffset
#3Z_3X_RangeOffset
#5Z_1X_RangeOffset
#-2Z_-5X_RangeOffset
#5ZRangeOffset
#-3XRangeOffset

#1X_1Z_Spawn
#-2X_0Z_Spawn
#0X_2Z_Spawn
#-1X_-1Z_Spawn
#-1X_-2Z_Spawn
#1X_4Z_Spawn
#0X_3Z_Spawn
#0X_-1Z_Spawn
#1X_0Z_Spawn
#2X_-2Z_Spawn
#2X_2Z_Spawn
#3X_3Z_Spawn
#1X_5Z_Spawn
#-5X_-2Z_Spawn





#spread the markers
execute as @s run execute as @e[type=marker,distance=..7,tag=PyramidSpawn2,tag=!Moved] run execute at @s run function zzzzdonotuse:mobspawners/spawnerstuff/pyramid/pyramidspawnerspreadcoord


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

##if KyuDummy3(nearby mob count) is more than 4, do not spawn any mobs
execute as @s[scores={KyuDummy3=5..}] run scoreboard players set @s KyuDummy -1000



#80% chance to spawn 1 mob, 20% chance to spawn 2 mobs
##redundancy on the spawners just in case
execute as @s[tag=SkeletonSpawner,scores={KyuDummy=0..7}] run tag @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=SkeletonMarker,limit=1,sort=random] add DoASpawn
execute as @s[tag=SkeletonSpawner,scores={KyuDummy=8..9}] run tag @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=SkeletonMarker,limit=2,sort=random] add DoASpawn
execute as @s[tag=ZombieSpawner,scores={KyuDummy=0..7}] run tag @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=ZombieMarker,limit=1,sort=random] add DoASpawn
execute as @s[tag=ZombieSpawner,scores={KyuDummy=8..9}] run tag @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=ZombieMarker,limit=2,sort=random] add DoASpawn
execute as @s[tag=BlazeSpawner,scores={KyuDummy=0..7}] run tag @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=BlazeMarker,limit=1,sort=random] add DoASpawn
execute as @s[tag=BlazeSpawner,scores={KyuDummy=8..9}] run tag @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=BlazeMarker,limit=2,sort=random] add DoASpawn
execute as @s[tag=CaveSpiderSpawner,scores={KyuDummy=0..7}] run tag @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=CaveSpiderMarker,limit=1,sort=random] add DoASpawn
execute as @s[tag=CaveSpiderSpawner,scores={KyuDummy=8..9}] run tag @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=CaveSpiderMarker,limit=2,sort=random] add DoASpawn
execute as @s[tag=SilverfishSpawner,scores={KyuDummy=0..7}] run tag @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=SilverfishMarker,limit=1,sort=random] add DoASpawn
execute as @s[tag=SilverfishSpawner,scores={KyuDummy=8..9}] run tag @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=SilverfishMarker,limit=2,sort=random] add DoASpawn
execute as @s run kill @e[type=marker,distance=..1,sort=nearest,tag=PyramidSpawnNum]




#spawn the mob
execute at @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=DoASpawn,tag=ZombieMarker] run summon husk ~ ~ ~ {Tags:["GKNameTag","NoMobMent"],PersistenceRequired:1b,Health:25f,Attributes:[{Name:generic.max_health,Base:25},{Name:generic.movement_speed,Base:.24},{Name:generic.attack_damage,Base:9}],HandItems:[{id:"minecraft:netherite_hoe",Count:1b},{}],ArmorItems:[{id:"minecraft:leather_boots",Count:1b,tag:{display:{color:13212765}}},{id:"minecraft:chainmail_leggings",Count:1b,tag:{display:{color:13212765}}},{id:"minecraft:leather_chestplate",Count:1b,tag:{display:{color:13212765}}},{id:"minecraft:player_head",Count:1b,tag:{SkullOwner:{Id:[I;-753657145,1904429937,-1977621215,-1215220278],Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmEwYmZlYzdlOTY5Njk0Njk0YWM0YTU3ZjBjMDdlYTM2MGJhMTQ0MzQ5MGYzMTUxMjA2MTc2NWRiZTRhNTM0NyJ9fX0="}]}}}}]}
execute at @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=DoASpawn,tag=SkeletonMarker] run summon skeleton ~ ~ ~ {Tags:["GKNameTag"],PersistenceRequired:1b,Health:20f,Attributes:[{Name:generic.max_health,Base:20}],HandItems:[{id:"minecraft:bow",Count:1b,tag:{Enchantments:[{id:"minecraft:power",lvl:3s},{id:"minecraft:punch",lvl:2s},{id:"minecraft:flame",lvl:1s}]}},{}],HandDropChances:[-327.000F,-327.000F],ArmorItems:[{id:"minecraft:leather_boots",Count:1b,tag:{display:{color:15714048}}},{id:"minecraft:chainmail_leggings",Count:1b,tag:{display:{color:15714048}}},{id:"minecraft:leather_chestplate",Count:1b,tag:{display:{color:15714048}}},{id:"minecraft:player_head",Count:1b,tag:{SkullOwner:{Id:[I;-1693098047,1009534297,-1920173089,252676858],Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDg5M2I3ZDE2N2NiM2Q1YWRlZjBlMjA0NDhlODgyMDEwMDViYjgwNTMyYWZkYWRjODAyNmMwOTZjNTU2ZDFiNCJ9fX0="}]}}}}]}
execute at @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=DoASpawn,tag=CaveSpiderMarker] run summon cave_spider ~ ~ ~
execute at @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=DoASpawn,tag=BlazeMarker] run summon blaze ~ ~ ~
execute at @e[type=marker,distance=..20,tag=PyramidSpawn2,tag=DoASpawn,tag=SilverfishMarker] run summon silverfish ~ ~ ~

#force mobs spawned to gain instant mob progression
#execute at @s run execute as @e[type=armor_stand,name=DayQ,limit=1] run function zzzzdonotuse:mobspawners/spawnerstuff/pyramid/pyramidforcechange



execute as @e[type=marker,distance=..20,tag=PyramidSpawn2,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=PyramidSpawn2,tag=DoASpawn] run execute at @s run playsound minecraft:entity.wither_skeleton.ambient hostile @a[distance=..7] ~ ~ ~ 1 0.85
execute as @e[type=marker,distance=..20,tag=PyramidSpawn2] run kill @s

# 1% chance to destroy the mob spawner and summon a live tnt
#execute if predicate suhc:1percent run tag @s add TimeToDielol
#execute at @s[tag=TimeToDielol] run setblock ~ ~ ~ air
#execute at @s[tag=TimeToDielol] run summon tnt ~ ~ ~ {Fuse:90}
#kill @s[tag=TimeToDielol]



