#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#
#    This function has been created by Skilendarz Group.
#             https://skilendarz.com
#
#      GIVE MAP MAKERS THE CREDIT THEY DESERVE!
#             COPYING IS PROHIBITED!
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#hover
scoreboard players set info wineffect_hover 0
execute as @p[distance=..6] at @s positioned ^ ^ ^0.5 run function f:lobby/info/info_loop

#display
execute as @e[tag=info,type=armor_stand] run data merge entity @s {Glowing:0}
execute if score info wineffect_hover matches 1 run particle minecraft:crit 321 112.4 -291 0.1 0 0.1 0 10 normal @a
execute if score info wineffect_hover matches 2 run particle minecraft:crit 321 112.4 -286 0.1 0 0.1 0 10 normal @a
execute if score info wineffect_hover matches 1 run data merge entity @e[tag=info_left,limit=1] {Glowing:1}
execute if score info wineffect_hover matches 2 run data merge entity @e[tag=info_right,limit=1] {Glowing:1}
execute unless score info main matches 3 as @p run loot replace entity @e[tag=info_player] armor.head loot f:head
execute if score info main matches 3 as @p run loot replace entity @e[tag=info_player2] armor.head loot f:head

effect clear @a[distance=..7] glowing
effect give @p[distance=..6] minecraft:glowing 1 0 true

#sound
execute unless score info wineffect_hover = info wineffect_sound as @a[distance=..6] at @s run playsound minecraft:entity.phantom.flap master @s ~ ~ ~ 1 2
scoreboard players operation info wineffect_sound = info wineffect_hover

#frames
execute as @p if score @s click matches 1.. if score info wineffect_hover matches 1 run scoreboard players remove info main 1
execute as @p if score @s click matches 1.. if score info wineffect_hover matches 2 run scoreboard players add info main 1
execute if score info main matches ..-1 run scoreboard players set info main 7
execute if score info main matches 8.. run scoreboard players set info main 0
execute as @p if score @s click matches 1.. if score info wineffect_hover matches 1..2 run function f:lobby/info/info_spawn
scoreboard players set @a[distance=..6] click 0

#animations
scoreboard players add info time 1

#1 (gold)
execute if score info main matches 1 if score info time matches 1 run scoreboard players set @e[tag=info_as] time -35
execute if score info main matches 1 if score info time matches 1..10 run scoreboard players remove @e[tag=info_as] time 5
execute if score info main matches 1 if score info time matches 11..12 run scoreboard players remove @e[tag=info_as] time 2
execute if score info main matches 1 if score info time matches 13..17 run scoreboard players add @e[tag=info_as] time 11
execute if score info main matches 1 if score info time matches 15.. run scoreboard players set info time 0

#2-5 (hand)
execute if score info main matches 2 if score info time matches 1 run scoreboard players set @e[tag=info_player] time 0
execute if score info main matches 4 if score info time matches 1 run scoreboard players set @e[tag=info_player] time 30
execute if score info main matches 2..5 if score info time matches 1..5 run scoreboard players remove @e[tag=info_player] time 10
execute if score info main matches 2..5 if score info time matches 6 run scoreboard players remove @e[tag=info_player] time 5
execute if score info main matches 2..5 if score info time matches 7..11 run scoreboard players add @e[tag=info_player] time 10
execute if score info main matches 2..5 if score info time matches 12 run scoreboard players add @e[tag=info_player] time 5

#2-3 (pumpkin)
execute if score info main matches 3 if score info time matches 5 at @e[tag=info_player2] run playsound minecraft:entity.warden.tendril_clicks master @a ~ ~1 ~ 0.5
execute if score info main matches 2..3 if score info time matches 6 as @e[tag=info_pumpkin] at @s run tp @s ~ 109.6 ~ 90 ~
execute if score info main matches 2..3 if score info time matches 6 at @e[tag=info_pumpkin] run particle minecraft:cloud ~ ~1.5 ~ 0 0 0 0.03 5
execute if score info main matches 2..3 if score info time matches 6..10 as @e[tag=info_pumpkin] at @s run tp @s ~ ~0.1 ~ ~30 ~
execute if score info main matches 2..3 if score info time matches 11 as @e[tag=info_pumpkin] at @s run tp @s ~ ~0.05 ~ ~30 ~
execute if score info main matches 2..3 if score info time matches 12..16 as @e[tag=info_pumpkin] at @s run tp @s ~ ~-0.1 ~ ~30 ~
execute if score info main matches 2..3 if score info time matches 17 as @e[tag=info_pumpkin] at @s run tp @s ~ ~-0.05 ~ ~30 ~

execute if score info main matches 2 if score info time matches 20.. run scoreboard players set info time 0
execute if score info main matches 3 if score info time matches 30.. run scoreboard players set info time 0

#4
execute if score info main matches 4 as @e[tag=info_player] run data merge entity @s {Pose:{Head:[0.01f,0.0f,0.0f]}}
execute if score info main matches 4 if score info time matches 1 run scoreboard players set @e[tag=info_player] chest 0
execute if score info main matches 4 if score info time matches 1..5 run scoreboard players remove @e[tag=info_player] chest 10
execute if score info main matches 4 if score info time matches 6 run scoreboard players remove @e[tag=info_player] chest 5
execute if score info main matches 4 if score info time matches 7..11 run scoreboard players add @e[tag=info_player] chest 10
execute if score info main matches 4 if score info time matches 12 run scoreboard players add @e[tag=info_player] chest 5
execute if score info main matches 4 if score info time matches 25.. run scoreboard players set info time 0
execute at @e[tag=info_particles] run particle minecraft:dust 1 0 0 1 ~0.3 ~0.5 ~ 0.2 0.2 0.2 0 10

#5
execute if score info main matches 5 as @e[tag=info_player] run data merge entity @s {Pose:{RightArm:[0.01f,0.0f,10.0f]}}
execute if score info main matches 5 if score info time matches 6 as @e[tag=info_player,limit=1] at @s run summon minecraft:snowball ~ ~1.5 ~ {Motion:[0.0,0.0,0.5],Rotation:[0.0f,0.0f]}

execute if score info main matches 5 if score info time matches 10 at @e[tag=info_player2] run summon firework_rocket ~ ~1 ~ {LifeTime:1,FireworksItem:{id:"firework_rocket",Count:1,tag:{Fireworks:{Explosions:[{Type:0,Colors:[I;12844856,8485119],FadeColors:[I;16744760,4587500]}]}}}}
execute if score info main matches 5 if score info time matches 10 run kill @e[tag=info_player2]
execute if score info main matches 5 if score info time matches 37 run particle minecraft:cloud 321 12 -287 0.3 0.4 0.3 0 100
execute if score info main matches 5 if score info time matches 40 run summon armor_stand 321 111 -287 {DisabledSlots:2039552,Invisible:1,NoGravity:1,ShowArms:1,Pose:{Head:[10f,20f,0f],LeftArm:[-40f,0f,10f]},Tags:["info_as","info_player2"],ArmorItems:[{id:"leather_boots",Count:1b,tag:{display:{color:12099684}}},{id:"leather_leggings",Count:1b,tag:{display:{color:13415025}}},{id:"leather_chestplate",Count:1b,tag:{display:{color:11546150}}},{id:"player_head",Count:1b}],HandItems:[{id:"lime_dye",Count:1b,tag:{CustomModelData:27}},{id:"lime_dye",Count:1b,tag:{CustomModelData:28}}],Silent:1}

#6
execute if score info main matches 6 if score info time matches 1 run summon armor_stand 321 111 -289.3 {DisabledSlots:2039552,Invisible:1,NoGravity:1,ShowArms:1,Pose:{Head:[10f,0f,0f],RightArm:[0.01f,0.01f,0.01f],LeftArm:[0.01f,0.01f,0.01f]},Tags:["info_as","info_player"],ArmorItems:[{id:"leather_boots",Count:1b,tag:{display:{color:12099684}}},{id:"leather_leggings",Count:1b,tag:{display:{color:13415025}}},{id:"leather_chestplate",Count:1b,tag:{display:{color:3949738}}},{id:"player_head",Count:1b}],HandItems:[{id:"lime_dye",Count:1b,tag:{CustomModelData:27}},{id:"lime_dye",Count:1b,tag:{CustomModelData:28}}],Silent:1}
execute if score info main matches 6 if score info time matches 1 at @e[tag=info_player] run particle minecraft:cloud ~ ~1 ~ 0.3 0.4 0.3 0 100

execute if score info main matches 6 run setblock 321 111 -288 minecraft:rail[shape=east_west]
execute if score info main matches 6 as @e[tag=info_player] run data merge entity @s {Pose:{RightArm:[0.01f,0.01f,0.01f],LeftArm:[0.01f,0.01f,0.01f],RightLeg:[0.01f,0.01f,0.01f],LeftLeg:[0.01f,0.01f,0.01f]}}
execute if score info main matches 6 run scoreboard players add info carrot 1

execute if score info main matches 6 if score info carrot matches 1 run scoreboard players set @e[tag=info_player] time 0
execute if score info main matches 6 if score info carrot matches 1..5 run scoreboard players remove @e[tag=info_player] time 5
execute if score info main matches 6 if score info carrot matches 6..7 run scoreboard players remove @e[tag=info_player] time 2
execute if score info main matches 6 if score info carrot matches 8..17 run scoreboard players add @e[tag=info_player] time 5
execute if score info main matches 6 if score info carrot matches 18..19 run scoreboard players add @e[tag=info_player] time 2
execute if score info main matches 6 if score info carrot matches 20..24 run scoreboard players remove @e[tag=info_player] time 5
execute if score info main matches 6 if score info carrot matches 24.. run scoreboard players set info carrot 0
execute if score info main matches 6 as @e[tag=info_player] at @s run tp @s ~ ~ ~0.05

execute if score info main matches 6 if score info time matches 50 at @e[tag=info_player] run particle minecraft:smoke ~ ~1 ~ 0.3 0.4 0.3 0 100
execute if score info main matches 6 if score info time matches 50 run kill @e[tag=info_player]

#7
execute as @e[tag=fake_powerup] at @s run function f:game/powerup/powerup

#final
execute if score info main matches 1..6 as @e[tag=info_as,tag=!info_sensor] store result entity @s Pose.RightArm[0] float 0.7 run scoreboard players get @s time
execute if score info main matches 6 as @e[tag=info_player] store result entity @s Pose.LeftArm[0] float -0.7 run scoreboard players get @s time
execute if score info main matches 6 as @e[tag=info_player] store result entity @s Pose.LeftLeg[0] float 1 run scoreboard players get @s time
execute if score info main matches 6 as @e[tag=info_player] store result entity @s Pose.RightLeg[0] float -1 run scoreboard players get @s time
execute if score info main matches 4 as @e[tag=info_player] store result entity @s Pose.RightArm[1] float 0.7 run scoreboard players get @s chest
execute if score info main matches 4 as @e[tag=info_player] store result entity @s Pose.Head[0] float -1 run scoreboard players get @s chest

execute if score info time matches 60.. run scoreboard players set info time 0