#####TL;DR - teleport @s to the surviving marker(survived all biome check conditions) that has the highest Y value, then create big triangle



#have the surviving markers run the next function, which has them teleport down and check the perimeter of the base of the perimeter for solid blocks, up to 50 times
execute as @e[type=marker,tag=PyramidCheck1,distance=..150,scores={KyuDummy=10..}] run execute at @s positioned ~ ~ ~ run function zzzzdonotuse:structures/pyramid/pyramidblockcheck2

#store the Y pos of @s and all the surviving markers in KyuDummy2
scoreboard players set @s KyuDummy2 -1000
#execute as @s run execute store result score @s KyuDummy2 run data get entity @s Pos[1] 1
execute as @e[type=marker,tag=PyramidCheck1,distance=..150,scores={KyuDummy=10..}] run scoreboard players set @s KyuDummy2 -1000
execute as @e[type=marker,tag=PyramidCheck1,distance=..150,scores={KyuDummy=10..}] run execute as @s run execute store result score @s KyuDummy2 run data get entity @s Pos[1] 1


#set the KyuDummy2 scoreboard of @s to the KyuDummy2 value(aka Y pos) of the surviving marker with the highest value, then add 1000
##I added 1000 to the scoreboards just as a redundant precaution - it is an entirely arbitrary number
execute as @s run scoreboard players operation @s KyuDummy2 > @e[type=marker,distance=..125,tag=PyramidCheck1,tag=!NoSpawn,scores={KyuDummy=10..}] KyuDummy2
execute as @e[type=marker,tag=PyramidCheck1,distance=..150,scores={KyuDummy2=-500..-1}] run scoreboard players add @s[scores={KyuDummy=10..}] KyuDummy2 1000
execute as @e[type=marker,tag=PyramidCheck1,distance=..150,scores={KyuDummy2=1..255}] run scoreboard players add @s[scores={KyuDummy=10..}] KyuDummy2 1000

#subtract @s KyuDummy2 from all the surviving markers, then teleport @s to a marker that has a scoreboard of exactly 1000
execute as @s run scoreboard players operation @e[type=marker,distance=..125,tag=PyramidCheck1,tag=!NoSpawn,scores={KyuDummy=10..}] KyuDummy2 -= @s KyuDummy2
execute as @s run execute at @s run tp @s @e[limit=1,sort=nearest,tag=PyramidCheck1,scores={KyuDummy2=1000},distance=..125]


#big triangle
execute at @s run execute if entity @e[tag=PyramidCheck1,scores={KyuDummy2=1000},distance=..3] run execute at @s positioned ~ ~28 ~ run function zzzzdonotuse:structures/pyramid/createtriangle


kill @e[tag=PyramidCheck1]
kill @s[type=marker]
