scoreboard players add @e[distance=..3,type=marker,tag=LanternEvent] KyuDummy 1

#at tick 6000, reset everything
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=6000..}] run execute in overworld run data merge block 999982 128 999980 {auto:0b}
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=6000..}] run kill @e[type=minecraft:armor_stand,tag=LanternEventStands]
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=6000..}] run kill @e[type=minecraft:armor_stand,tag=LanternEventStandsBlock]
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=6000..}] run kill @e[type=minecraft:falling_block,tag=LanternSand]
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=6000..}] run execute as @e[type=armor_stand,name=DayQ] run tag @s remove LanternEventDay
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=6000..}] run execute as @e[type=armor_stand,name=DayQ] run tag @s remove LanternStartText
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=6000..}] run execute as @e[type=armor_stand,name=DayQ] run tag @s remove LanternStartV2
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=6000..}] run tellraw @a[tag=K] ["",{"text":"A random event has un-occurred!","color":"yellow","italic":true}]
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=6000..}] run tellraw @a[tag=K] ["",{"text":"As the night ends, that terrible feeling of dread returns. However, you still feel as if the darkness engulfs you a tiny bit less.","color":"dark_red","italic":true}]
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=6000..}] run time set 21500
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=6000..}] run tag @e[type=armor_stand,name=DayQ] add KillNextDarkness
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=6000..}] run kill @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=6000..}]

#no sleeping allowed
tag @a[nbt=!{SleepTimer:0s}] add STAHP
tellraw @a[tag=K,tag=STAHP] ["",{"text":"There's an event happening right now! You wouldn't want to miss it, would you?","color":"red"}]
execute as @a[tag=STAHP] run execute at @s run tp @s ~ ~.1 ~
tag @a remove STAHP

#execute as @s[tag=LanternEventDay,tag=!LanternStartText] run execute if entity @s[scores={KyuTime=11500..11900}] run 
#execute as @s[tag=LanternEventDay,tag=!LanternStartText] run execute if entity @s[scores={KyuTime=11500..11900}] run tellraw @a[tag=K] ["",{"text":"","color":"dark_red","italic":true}]

#delete mob follow range
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=..5999}] run execute if predicate suhc:10percent run execute as @e[type=#suhc:hostiles,tag=!ReturnFollowRange] run function zzzzdonotuse:randomevent/lanterns/mobfollowrange


##do some tagging stuff and make sure lanterns and fireworks only spawn on one player in a particular "group" of players, to prevent a thousand lanterns from spawning in one area
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=..5000}] run execute as @a[predicate=suhc:overworld,gamemode=!spectator] run function zzzzdonotuse:randomevent/lanterns/tagplayers
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=..5000}] run execute at @a[predicate=suhc:overworld,tag=LanternSpawn,tag=!NoLanternSpawn] run execute if predicate suhc:75percent run execute if predicate suhc:50percent run execute if predicate suhc:10percent run function zzzzdonotuse:randomevent/lanterns/lanternsspawn
execute if entity @e[distance=..3,type=marker,tag=LanternEvent,scores={KyuDummy=..5800}] run execute at @a[predicate=suhc:overworld,tag=LanternSpawn,tag=!NoLanternSpawn] run execute if predicate suhc:10percent run function zzzzdonotuse:randomevent/lanterns/fireworkspawn
tag @a remove LanternSpawn
tag @a remove NoLanternSpawn

#make lanterns move, or shine if they're on the ground
execute as @e[type=armor_stand,tag=LanternEventStands] run function zzzzdonotuse:randomevent/lanterns/lanternsmove
execute as @e[type=armor_stand,tag=LanternEventStandsBlock] run function zzzzdonotuse:randomevent/lanterns/lanternsgroundblock




