#why
##serious spaghet here
###what even are these scoreboard names

#keeping old code for archival and....entertainment purposes

###scoreboard players add @s EQK 1
###execute at @e[sort=random,limit=1,type=armor_stand,name=METEORKYU] if block ~ ~-1 ~ bedrock run scoreboard players add @s TKQ 1
###execute at @s[scores={TKQ=1..2}] run summon armor_stand ~ 210 ~ {NoGravity:1,Invisible:1b,Silent:1b,Inulvnerable:1,CustomName:"\"Meteor\"",NoAI:1,active_effects:[{id:"minecraft:invisibility",amplifier:0,duration:10000}]}
###scoreboard players set @s[scores={EQK=9150..}] EQK 9000
###
###
###execute unless entity @e[type=armor_stand,name=Meteor] run execute if entity @s[tag=!NoMetStorm] run execute at @a[limit=1,sort=random,tag=K,nbt={Dimension:"minecraft:overworld"}] run summon armor_stand ~ 210 ~ {NoGravity:1,Invisible:1b,Silent:1b,Inulvnerable:1,CustomName:"\"Meteor\"",NoAI:1,active_effects:[{id:"minecraft:invisibility",amplifier:0,duration:10000}]}
###execute at @a[limit=1,sort=random,tag=K,nbt={Dimension:"minecraft:overworld"}] run spreadplayers ~ ~ 1 155 false @e[type=armor_stand,name=Meteor]
###
###
###
###execute as @e[type=minecraft:armor_stand,name=Meteor] run execute at @s positioned ~ ~ ~ run tp @s ~ 255 ~
###execute at @s[scores={EQK=9149}] run execute at @a[tag=K] run tag @e[distance=..9,type=item,tag=!SaveItem,tag=!ItemSave] add ItemSave
###execute at @s[scores={EQK=9149}] run execute at @a[tag=K] run kill @e[distance=..150,type=item,tag=!SaveItem,tag=!ItemSave]
###
###
###execute at @s[scores={TKQ=51..400}] run execute if entity @s[tag=!NoMetStorm] run execute at @e[type=armor_stand,sort=random,name=Meteor,limit=1] positioned ~ ~-3 ~ run summon fireball ~ 255 ~ {CustomName:"\"i\"",direction:[0.0,-0.2,0.0],power:[0.0,-0.2,0.0],ExplosionPower:2}
###execute at @s[scores={TKQ=498..499}] run kill @e[type=armor_stand,name=Meteor]
###execute at @s[scores={TKQ=498..499}] run kill @e[type=item,tag=!SaveItem,tag=!ItemSave]
###execute at @s[scores={TKQ=498..499}] run kill @e[type=fireball,name=i]
###execute at @s[scores={TKQ=498..499}] run kill @e[name=Explodey0]
###execute at @a run tag @e[distance=..5,name=!Explodey] add NoSplode
###
###execute at @s[scores={TKQ=499..500}] run execute at @s run data merge block 999982 122 999980 {auto:0b}




#see below













##KyuDummy can start anywhere from 0-600, making the meteor storm last anywhere from 30-60 seconds
scoreboard players add @e[distance=..3,type=marker,tag=MeteorStormEvent] KyuDummy 1
scoreboard players add @e[distance=..3,type=marker,tag=MeteorStormEvent] KyuDummy2 1

#make sure meteors don't spawn on multiple people who are close together. Also, limit the max to 5 per tick.
execute as @a[tag=K,nbt={Dimension:"minecraft:overworld"},tag=!NoSpawnMeteor] run execute at @s run function zzzzdonotuse:randomevent/meteorstorm/meteorstormplayertag
execute as @a[tag=K,tag=SpawnMeteorOnMe,tag=!NoSpawnMeteor,limit=5,sort=random] run execute at @s run function zzzzdonotuse:randomevent/meteorstorm/summonmeteor1
tag @a remove SpawnMeteorOnMe
tag @a remove NoSpawnMeteor


#kill all items every 150 ticks, excluding ones close to players
execute if entity @e[distance=..3,type=marker,tag=MeteorStormEvent,scores={KyuDummy2=150..}] run execute as @e[distance=..3,type=marker,tag=MeteorStormEvent] run function zzzzdonotuse:randomevent/meteorstorm/itemkill


#reset at the end of the timer duration
execute if entity @e[distance=..3,type=marker,tag=MeteorStormEvent,scores={KyuDummy=1200..}] run execute as @e[distance=..3,type=marker,tag=MeteorStormEvent] run function zzzzdonotuse:randomevent/meteorstorm/itemkill
execute if entity @e[distance=..3,type=marker,tag=MeteorStormEvent,scores={KyuDummy=1200..}] run execute in overworld run data merge block 999982 122 999980 {auto:0b}
execute if entity @e[distance=..3,type=marker,tag=MeteorStormEvent,scores={KyuDummy=1200..}] run kill @e[distance=..3,type=marker,tag=MeteorStormEvent,scores={KyuDummy=1200..}]



execute unless entity @e[distance=..3,type=marker,tag=MeteorStormEvent] run execute in overworld run data merge block 999982 122 999980 {auto:0b}








































