setblock 999976 124 999978 repeating_command_block[facing=up]{auto:1b,Command:"scoreboard players add @e[type=armor_stand,name=DayQ] DQT 2",TrackOutput:0} destroy
setblock 999976 125 999978 chain_command_block[conditional=true,facing=up]{auto:1b,Command:"execute at @e[type=armor_stand,name=DayQ,scores={DQT=300..}] run scoreboard players set @e[type=armor_stand,name=DayQ] DQT 0",TrackOutput:0} destroy
setblock 999976 127 999978 chain_command_block[facing=up]{auto:1b,Command:"execute at @e[type=armor_stand,name=DayQ,scores={DQT=28}] run kill @e[distance=..7,type=item]",TrackOutput:0} destroy
data merge block 999976 128 999978 {Command:"",auto:0b}
setblock 999976 129 999978 chain_command_block[facing=up]{auto:1b,Command:"execute at @e[type=armor_stand,name=DayQ,scores={DQT=8}] run fill ~3 ~ ~-8 ~-1 ~-1 ~3 redstone_block replace bedrock",TrackOutput:0} destroy
setblock 999976 131 999978 chain_command_block[facing=up]{auto:1b,Command:"execute at @e[type=armor_stand,name=DayQ,scores={DQT=12}] run execute at @e[type=item,scores={EQK=1..29}] run tellraw @a[tag=K] [\"\",{\"text\":\"A random event has occured!\",\"color\":\"yellow\",\"italic\":true}]",TrackOutput:0} destroy
setblock 999979 156 999975 repeating_command_block[facing=up]{auto:1b,Command:"scoreboard players add @e[type=armor_stand,name=DayQ] 10TickTimer 1",TrackOutput:0} destroy
setblock 999979 157 999975 chain_command_block[facing=up]{auto:1b,Command:"scoreboard players set @e[type=armor_stand,name=DayQ,scores={10TickTimer=10..}] 10TickTimer 0",TrackOutput:0} destroy
data merge block 999979 163 999975 {auto:0b}
setblock 999979 160 999975 chain_command_block[facing=up]{auto:1b,Command:"/function zzzzdonotuse:halfsec/main",TrackOutput:0} destroy
setblock 999979 168 999975 chain_command_block[facing=up]{auto:1b,Command:"/function zzzzdonotuse:halfsec/main2",TrackOutput:0} destroy
setblock 999979 161 999975 chain_command_block[facing=up]{auto:0b,Command:"",TrackOutput:0} destroy
setblock 999979 165 999975 chain_command_block[facing=up]{auto:0b,Command:"",TrackOutput:0} destroy
fill 999979 169 999975 999979 173 999975 chain_command_block[facing=up]{auto:0b,Command:"",TrackOutput:0} destroy
setblock 999978 162 999975 chain_command_block[facing=up]{auto:1b,Command:"/function zzzzdonotuse:halfsec/trinketandluck",TrackOutput:0} destroy
fill 999978 163 999975 999978 173 999975 chain_command_block[facing=up]{auto:0b,Command:"",TrackOutput:0} destroy
fill 999978 182 999975 999978 183 999975 chain_command_block[facing=up]{auto:0b,Command:"",TrackOutput:0} destroy
data merge block 999977 161 999977 {auto:0b}
setblock 999999 120 999975 air
setblock 999982 137 999976 chain_command_block[facing=up]{auto:1b,Command:"clear @a[tag=K,tag=!KyuNat,nbt=!{Inventory:[{id:\"minecraft:bread\",tag:{Enchantments:[{id:\"minecraft:mending\"}]}}]}] bread",TrackOutput:0} destroy
setblock 999977 203 999977 chain_command_block[facing=up]{auto:1b,Command:"execute at @e[type=armor_stand,scores={KyuLake=1202..}] run summon armor_stand ~ ~ ~ {Tags:[\"ECStand\"],CustomName:\"\\\"KyuChestNone\\\"\",NoGravity:1,Invulnerable:1,Invisible:1b,Silent:1b}",TrackOutput:0} destroy
setblock 999978 151 999975 chain_command_block[facing=up]{auto:1b,Command:"execute at @a run execute as @e[distance=..30,name=KyuChestNone] run data merge entity @s {Tags:[\"ECStand\"],CustomName:\"\\\"KyuChest\\\"\",DisabledSlots:4144959}",TrackOutput:0} destroy
data merge block 999978 156 999975 {Command:"execute at @e[type=armor_stand,name=KyuChest] positioned ~24 0 ~ run data merge block ~ ~ ~ {TransferCooldown:0}",TrackOutput:0}
setblock 999986 159 999978 chain_command_block[facing=up]{auto:1b,Command:"execute at @e[name=OreL] positioned ~ 11 ~ run summon armor_stand ~ ~ ~ {CustomName:\"\\\"KyuLake\\\"\",Tags:[\"ECStand\"],NoGravity:1,Invulnerable:1,Invisible:1b,Silent:1b,DisabledSlots:4144959,Small:1b}",TrackOutput:0} destroy
setblock 999980 126 999976 chain_command_block[facing=up]{auto:1b,Command:"function zzzzdonotuse:randomevent/lightning",TrackOutput:0} destroy
setblock 999982 133 999975 chain_command_block[facing=up]{auto:1b,Command:"execute at @e[type=armor_stand,name=QDK,tag=!SaveTorch] run fill ~-79 ~ ~-79 ~79 ~ ~79 redstone_torch replace torch",TrackOutput:0} destroy
setblock 999982 127 999975 minecraft:chain_command_block[facing=up] destroy
#
setblock 999995 121 999977 chain_command_block[facing=up]{auto:1b,Command:"execute as @a[tag=LocateSpell2,scores={KyuSpells=9}] run execute at @s run execute if entity @e[tag=ECStand,distance=0..20] run tellraw @s [\"\",{\"text\":\"You're inside an ancient cavern right now! Why are you using this spell?\",\"color\":\"green\"}]",TrackOutput:0} destroy
setblock 999995 122 999977 chain_command_block[facing=up]{auto:1b,Command:"execute as @a[tag=LocateSpell2,scores={KyuSpells=9}] run execute at @s run execute if entity @e[tag=ECStand,distance=21..40] run tellraw @s [\"\",{\"text\":\"There is an ancient cavern so closely nearby you can almost taste it...\",\"color\":\"aqua\"}]",TrackOutput:0} destroy
setblock 999995 123 999977 chain_command_block[facing=up]{auto:1b,Command:"execute as @a[tag=LocateSpell2,scores={KyuSpells=9}] run execute at @s run execute if entity @e[tag=ECStand,distance=41..80] run tellraw @s [\"\",{\"text\":\"There is an ancient cavern fairly close nearby.\",\"color\":\"yellow\"}]",TrackOutput:0} destroy
setblock 999995 124 999977 chain_command_block[facing=up]{auto:1b,Command:"execute as @a[tag=LocateSpell2,scores={KyuSpells=9}] run execute at @s run execute if entity @e[tag=ECStand,distance=81..120] run tellraw @s [\"\",{\"text\":\"There is an ancient cavern a fair distance away.\",\"color\":\"gold\"}]",TrackOutput:0} destroy
setblock 999995 125 999977 chain_command_block[facing=up]{auto:1b,Command:"execute as @a[tag=LocateSpell2,scores={KyuSpells=9}] run execute at @s run execute if entity @e[tag=ECStand,distance=121..250] run tellraw @s [\"\",{\"text\":\"There is an ancient cavern a long ways away.\",\"color\":\"red\"}]",TrackOutput:0} destroy
setblock 999995 126 999977 chain_command_block[facing=up]{auto:1b,Command:"execute as @a[tag=LocateSpell2,scores={KyuSpells=9}] run execute at @s run execute unless entity @e[tag=ECStand,distance=0..250] run tellraw @s [\"\",{\"text\":\"There is no ancient cavern located nearby.\",\"color\":\"dark_red\"}]",TrackOutput:0} destroy
#
scoreboard objectives add KillECChestTimer dummy
setblock 999997 144 999977 chain_command_block[facing=up]{auto:1b,Command:"function zzzzdonotuse:daytimer/enchantedcavern",TrackOutput:0} destroy
setblock 999997 145 999977 air destroy
#
tag @e[name=KyuPatch,type=armor_stand] add PatchOnePointTwoPointTwo
tellraw @a ["",{"text":"Patch 1.2.2 has been installed!","color":"gold"},{"text":"","color":"red"}]
execute as @e[tag=CurrentPatch] run data merge entity @s[tag=CurrentPatch] {CustomName:"\"Patch 1.2.2\"",Tags:["CurrentPatch"],NoGravity:1,Invisible:1b,Silent:1b,Invulnerable:1}