#summon a bunch of markers
summon minecraft:marker ~ ~ ~ {Tags:["PyramidCheck1"]}
summon minecraft:marker ~ ~ ~ {Tags:["PyramidCheck1"]}
summon minecraft:marker ~ ~ ~ {Tags:["PyramidCheck1"]}
summon minecraft:marker ~ ~ ~ {Tags:["PyramidCheck1"]}
summon minecraft:marker ~ ~ ~ {Tags:["PyramidCheck1"]}
summon minecraft:marker ~ ~ ~ {Tags:["PyramidCheck1"]}
summon minecraft:marker ~ ~ ~ {Tags:["PyramidCheck1"]}
summon minecraft:marker ~ ~ ~ {Tags:["PyramidCheck1"]}
summon minecraft:marker ~ ~ ~ {Tags:["PyramidCheck1"]}
summon minecraft:marker ~ ~ ~ {Tags:["PyramidCheck1"]}
summon minecraft:marker ~ ~ ~ {Tags:["PyramidCheck1"]}
summon minecraft:marker ~ ~ ~ {Tags:["PyramidCheck1"]}
summon minecraft:marker ~ ~ ~ {Tags:["PyramidCheck1"]}
summon minecraft:marker ~ ~ ~ {Tags:["PyramidCheck1"]}
spreadplayers ~ ~ 10 50 false @e[type=marker,tag=PyramidCheck1]






#execute as @e[type=marker,tag=PyramidCheck1,tag=NoSpawn] run execute at @s positioned ~ ~ ~ run function zzzzdonotuse:structures/pyramid/ylevellower
#execute as @e[type=marker,tag=PyramidCheck1,tag=NoSpawn] run execute store result entity @s Pos[1] double 1 run scoreboard players get @s KyuDummy2

#spread those checks
#spreadplayers ~ ~ 5 50 false @e[type=marker,tag=PyramidCheck1]

#sometimes the markers get placed on blocks such as leaves, flowers or tall_grass, so move them down if so
##yes that is the log cabin function, bite me
execute as @e[type=marker,tag=PyramidCheck1] run execute at @s positioned ~ ~ ~ run function zzzzdonotuse:structures/logcabin/logcabinmovedown

#run the block-check function as(and at) each marker, 1 block above ground level as thats where the structure block is located within the structure.nbt
execute as @e[type=marker,tag=PyramidCheck1] run execute at @s positioned ~ ~ ~ run function zzzzdonotuse:structures/pyramid/pyramidblockcheck

#if at least 7 of the markers succeed in the biome/water check function above, add a tag to the main marker and run the lookforspot function
scoreboard players set @s KyuDummy2 0
execute at @e[type=marker,tag=PyramidCheck1,distance=..150,scores={KyuDummy=10..}] run scoreboard players add @s KyuDummy2 1
execute as @s[scores={KyuDummy2=7..}] run tag @s add FoundAppMarker
execute at @s[tag=FoundAppMarker] run tag @s add GotPlaceSpot
execute at @s[tag=FoundAppMarker] run scoreboard players set @s KyuDummy5 20
execute at @s[tag=FoundAppMarker] run execute at @s positioned ~ ~ ~ run summon minecraft:marker ~ ~ ~ {Tags:["GibTriangle"]}
#execute at @s[tag=FoundAppMarker] run execute at @s positioned ~ ~ ~ run execute as @e[type=marker,limit=1,distance=..5,tag=GibTriangle] run function zzzzdonotuse:structures/pyramid/pyramidblockcheck2
execute at @s[tag=FoundAppMarker] run execute at @s positioned ~ ~ ~ run execute as @e[type=marker,limit=1,distance=..5,tag=GibTriangle] run function zzzzdonotuse:structures/pyramid/lookforspot
































##spread the markers around
#spreadplayers ~ ~ 5 60 false @e[type=marker,tag=PyramidCheck1]
#
#
#scoreboard players set @s KyuDummy 256
##execute as @e[type=marker,tag=PyramidCheck1] run execute store result score @s KyuDummy run data get entity @s Pos[1] 1
##execute as @e[type=marker,tag=PyramidCheck1] run scoreboard players operation @e[type=marker,sort=nearest,limit=1,tag=PyramidMarkerSpawnMain] KyuDummy < @s KyuDummy
##
#
#
#
##run the block-check function as(and at) each marker, 1 block above ground level as thats where the structure block is located within the structure.nbt
#execute as @e[type=marker,tag=PyramidCheck1] run execute at @s positioned ~ ~ ~ run function zzzzdonotuse:structures/pyramid/pyramidblockcheck
#
##teleport the main marker to a random marker from above that survived the function run(which checks the structure borders for appropriate spawning conditions)
#tp @s @e[type=marker,tag=PyramidCheck1,limit=1,sort=random,distance=..150]
#
#execute at @s run execute if entity @e[type=marker,tag=PyramidCheck1,distance=..4,scores={KyuDummy=10..}] run tag @s add CreateStructure
#
#execute at @s[tag=CreateStructure] run execute at @s positioned ~-28 ~ ~-28 run function zzzzdonotuse:structures/pyramid/perimetermarkers
#execute at @s[tag=CreateStructure] run execute as @e[type=marker,tag=PyramidGoDown] run function zzzzdonotuse:structures/pyramid/teleportdown
#execute at @s[tag=CreateStructure] run execute store result entity @s Pos[1] double 1 run scoreboard players get @s KyuDummy
#
#execute at @s[tag=CreateStructure] run execute at @s positioned ~-28 ~ ~-28 run function zzzzdonotuse:structures/pyramid/perimetermarkers
#execute at @s[tag=CreateStructure] run execute as @e[type=marker,tag=PyramidGoDown] run function zzzzdonotuse:structures/pyramid/teleportdown
#execute at @s[tag=CreateStructure] run execute store result entity @s Pos[1] double 1 run scoreboard players get @s KyuDummy
#
#execute at @s[tag=CreateStructure] positioned ~ ~28 ~ run function zzzzdonotuse:structures/pyramid/createtriangle
#
##if the main marker gets teleported successfuly to a marker with the appropriate conditions, place the structure
##execute at @s run execute if entity @e[type=marker,tag=PyramidCheck1,distance=..4,scores={KyuDummy=13..}] run setblock ~ ~1 ~ minecraft:structure_block[mode=load]{name:"suhc:logcabin",posX:-9,posZ:-6,posY:-4,rotation:NONE,mirror:NONE,mode:LOAD,ignoreEntities:0b} destroy
##execute at @s run execute if entity @e[type=marker,tag=PyramidCheck1,distance=..4,scores={KyuDummy=13..}] run setblock ~ ~2 ~ redstone_block
##execute at @s run execute if entity @e[type=marker,tag=PyramidCheck1,distance=..4,scores={KyuDummy=13..}] run tag @s add GotPlaceSpot
##execute at @s run execute if entity @e[type=marker,tag=PyramidCheck1,distance=..4,scores={KyuDummy=13..}] run scoreboard players set @s KyuDummy5 20
#
#
#kill @s[type=marker]