execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_1to6 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.x double 0.1 run data get entity @s Pos[0] 10
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_1to6 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.y double 0.1 run data get entity @s Pos[1] 12
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_1to6 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.z double 0.1 run data get entity @s Pos[2] 10

execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_7to12 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.x double 0.1 run data get entity @s Pos[0] 10
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_7to12 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.y double 0.1 run data get entity @s Pos[1] 11
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_7to12 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.z double 0.1 run data get entity @s Pos[2] 10

execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_13to32 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.x double 0.1 run data get entity @s Pos[0] 10
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_13to32 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.y double 0.1 run data get entity @s Pos[1] 10.5
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_13to32 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.z double 0.1 run data get entity @s Pos[2] 10

execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_33to64 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.x double 0.1 run data get entity @s Pos[0] 10
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_33to64 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.y double 0.1 run data get entity @s Pos[1] 10.2
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_33to64 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.z double 0.1 run data get entity @s Pos[2] 10

execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_65to128 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.x double 0.1 run data get entity @s Pos[0] 10
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_65to128 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.y double 0.1 run data get entity @s Pos[1] 10.12
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_65to128 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.z double 0.1 run data get entity @s Pos[2] 10

execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_129to192 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.x double 0.1 run data get entity @s Pos[0] 10
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_129to192 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.y double 0.1 run data get entity @s Pos[1] 10.05
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_129to192 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.z double 0.1 run data get entity @s Pos[2] 10

execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_192to256 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.x double 0.1 run data get entity @s Pos[0] 10
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_192to256 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.y double 0.1 run data get entity @s Pos[1] 10.04
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_192to256 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.z double 0.1 run data get entity @s Pos[2] 10

execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_256to320 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.x double 0.1 run data get entity @s Pos[0] 10
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_256to320 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.y double 0.1 run data get entity @s Pos[1] 10.03
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if predicate kiwi3:player_y_level_256to320 if score @s ancient_grimoire_chain matches ..500 as @s store result storage kiwi:ancient_grimoire_chain_pos pos.z double 0.1 run data get entity @s Pos[2] 10

execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if score @s ancient_grimoire_chain matches ..500 if entity @s[nbt={HurtTime:10s}] run playsound minecraft:block.chain.break master @a[distance=..8] ~ ~ ~ 0.5 1
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if score @s ancient_grimoire_chain matches ..500 run effect give @s slowness 1 255 true
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if score @s ancient_grimoire_chain matches 1 run function kiwi3:relics/ancient_grimoire/ancient_grimoire_chain_end

execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if score @s ancient_grimoire_chain matches ..500 as @s run function kiwi3:relics/ancient_grimoire/chain_macros/ancient_grimoire_chain_macro_1 with storage kiwi:ancient_grimoire_chain_pos pos
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if score @s ancient_grimoire_chain matches ..500 as @s run function kiwi3:relics/ancient_grimoire/chain_macros/ancient_grimoire_chain_macro_1.2 with storage kiwi:ancient_grimoire_chain_pos pos
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if score @s ancient_grimoire_chain matches ..500 as @s run function kiwi3:relics/ancient_grimoire/chain_macros/ancient_grimoire_chain_macro_2 with storage kiwi:ancient_grimoire_chain_pos pos
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if score @s ancient_grimoire_chain matches ..500 as @s run function kiwi3:relics/ancient_grimoire/chain_macros/ancient_grimoire_chain_macro_2.2 with storage kiwi:ancient_grimoire_chain_pos pos
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if score @s ancient_grimoire_chain matches ..500 as @s run function kiwi3:relics/ancient_grimoire/chain_macros/ancient_grimoire_chain_macro_3 with storage kiwi:ancient_grimoire_chain_pos pos
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if score @s ancient_grimoire_chain matches ..500 as @s run function kiwi3:relics/ancient_grimoire/chain_macros/ancient_grimoire_chain_macro_3.2 with storage kiwi:ancient_grimoire_chain_pos pos
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if score @s ancient_grimoire_chain matches ..500 as @s run function kiwi3:relics/ancient_grimoire/chain_macros/ancient_grimoire_chain_macro_4 with storage kiwi:ancient_grimoire_chain_pos pos
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if score @s ancient_grimoire_chain matches ..500 as @s run function kiwi3:relics/ancient_grimoire/chain_macros/ancient_grimoire_chain_macro_4.2 with storage kiwi:ancient_grimoire_chain_pos pos

execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if score @s ancient_grimoire_chain matches ..500 as @s run effect give @s slowness 1 255 true
execute as @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] at @s if score @s ancient_grimoire_chain matches ..500 as @s run scoreboard players remove @s ancient_grimoire_chain 1

execute if entity @e[tag=ancient_grimoire_chain,scores={ancient_grimoire_chain=0..500}] run schedule function kiwi3:relics/ancient_grimoire/ancient_grimoire_chain_fx 1t
