################################################################################################
#
# Jungle Temple
#
################################################################################################

scoreboard objectives add boulder_rot dummy
scoreboard objectives add boulder_timer dummy
scoreboard objectives add door_timer dummy
scoreboard objectives add gamestate dummy
scoreboard objectives add gem_timer dummy
scoreboard objectives add death deathCount
scoreboard objectives add sneak minecraft.custom:minecraft.sneak_time
scoreboard objectives add talk minecraft.custom:minecraft.talked_to_villager
scoreboard objectives add sneak_exit dummy
scoreboard objectives add was_swinging dummy
scoreboard objectives add swing_used dummy
scoreboard objectives add swing_start dummy
scoreboard objectives add rot_player dummy
scoreboard objectives add pillar_timer dummy
scoreboard objectives add ladder_unlock dummy
scoreboard objectives add swing_sound_cd dummy
scoreboard objectives add wall_timer dummy
scoreboard objectives add wall_state dummy
scoreboard objectives add r dummy
scoreboard objectives add laser_spawn dummy
scoreboard objectives add laser_rot dummy
scoreboard objectives add mirror_rot dummy
scoreboard objectives add mirror_y dummy
scoreboard objectives add init_mirror_rot dummy
scoreboard objectives add cage_timer dummy
scoreboard objectives add emerald_active dummy
scoreboard objectives add laser_active dummy


################################################################# General ################################################################

effect give @a saturation 99999 9 true
effect give @e[tag=invis] invisibility 9 9 true

################################################################################ Gamestate ##############################################################################

execute as @e[tag=sh,scores={gamestate=0}] if entity @a[x=28,y=73,z=696,distance=..4] run scoreboard players set @e[tag=sh] door_timer 1
execute as @e[tag=sh,scores={gamestate=0}] if entity @a[x=28,y=73,z=696,distance=..4] run tag @a remove trapped
execute as @e[tag=sh,scores={gamestate=0}] if entity @a[x=28,y=73,z=696,distance=..4] run tag @a[x=28,y=73,z=696,limit=1,sort=nearest] add trapped
execute as @e[tag=sh,scores={gamestate=0}] if entity @a[x=28,y=73,z=696,distance=..4] run scoreboard players set @e[tag=sh] gamestate 1



################################################################################ Mirror Laser Puzzle ##############################################################################

scoreboard players remove @e[tag=sh] laser_active 1
scoreboard players set @e[tag=sh,scores={gamestate=3}] laser_active 300

execute as @e[tag=sh,scores={laser_active=1..}] run function jungle_temple:laser_game


################################################################################ Wall Puzzle ##############################################################################
scoreboard players set @e[tag=wall] wall_state 0
scoreboard players add @e[tag=wall] wall_timer 0
scoreboard players add @e[tag=wall,scores={wall_timer=1..39}] wall_timer 1
scoreboard players add @e[tag=wall,scores={wall_timer=..-1}] wall_timer 1

execute if block 20 73 676 minecraft:lever[powered=false] run scoreboard players add @e[tag=wall_tag1] wall_state 1
execute if block 17 73 676 minecraft:lever[powered=false] run scoreboard players add @e[tag=wall_tag2] wall_state 1
execute if block 14 73 676 minecraft:lever[powered=false] run scoreboard players add @e[tag=wall_tag3] wall_state 1

execute if block 23 73 690 minecraft:lever[powered=false] run scoreboard players add @e[tag=wall_tag4] wall_state 1
execute if block 23 73 686 minecraft:lever[powered=false] run scoreboard players add @e[tag=wall_tag5] wall_state 1
execute if block 13 73 690 minecraft:lever[powered=false] run scoreboard players add @e[tag=wall_tag6] wall_state 1
execute if block 13 73 686 minecraft:lever[powered=false] run scoreboard players add @e[tag=wall_tag7] wall_state 1

execute as @e[tag=wall] run scoreboard players operation @s wall_state %= 2 constant
scoreboard players set @e[tag=wall_center,scores={wall_state=0,wall_timer=40..}] wall_timer -40
scoreboard players set @e[tag=wall_center,scores={wall_state=1,wall_timer=0}] wall_timer 1

execute as @e[tag=wall,scores={wall_timer=2}] at @s run function jungle_temple:random_stone_drag_sound
execute as @e[tag=wall,scores={wall_timer=2}] at @s run fill ~-1 ~2 ~ ~1 ~ ~ air
execute as @e[tag=wall,scores={wall_timer=2}] at @s run summon armor_stand ~ ~-1 ~ {Tags:[wall_move],NoGravity:1,Invisible:1}
execute as @e[tag=wall,scores={wall_timer=3}] at @s run execute as @e[tag=wall_move,limit=1,sort=nearest,distance=..3] at @s run data merge entity @s {ArmorItems:[{},{},{},{id:"minecraft:diamond_pickaxe",Count:1,tag:{Unbreakable:1,Damage:9}}]}
execute as @e[tag=wall,scores={wall_timer=3..32}] at @s run execute as @e[tag=wall_move,limit=1,sort=nearest,distance=..3] at @s run tp @s ~ ~0.1 ~
execute as @e[tag=wall,scores={wall_timer=34}] at @s run kill @e[tag=wall_move,sort=nearest,distance=..3]
execute as @e[tag=wall,scores={wall_timer=35}] at @s run fill ~-1 ~ ~ ~1 ~ ~ polished_andesite
execute as @e[tag=wall,scores={wall_timer=35}] at @s run fill ~-1 ~1 ~ ~1 ~2 ~ stone_bricks
execute as @e[tag=wall,scores={wall_timer=16}] at @s run fill ~1 ~ ~ ~-1 ~ ~ end_rod
execute as @e[tag=wall,scores={wall_timer=26}] at @s run fill ~-1 ~ ~ ~1 ~1 ~ end_rod

execute as @e[tag=wall,scores={wall_timer=-38}] at @s run function jungle_temple:random_stone_drag_sound
execute as @e[tag=wall,scores={wall_timer=-38}] at @s run fill ~-1 ~2 ~ ~1 ~ ~ air
execute as @e[tag=wall,scores={wall_timer=-38}] at @s run fill ~1 ~1 ~ ~-1 ~ ~ end_rod
execute as @e[tag=wall,scores={wall_timer=-39}] at @s run summon armor_stand ~ ~2 ~ {Tags:[wall_move],NoGravity:1,Invisible:1}
execute as @e[tag=wall,scores={wall_timer=-38}] at @s run execute as @e[tag=wall_move,limit=1,sort=nearest,distance=..3] at @s run data merge entity @s {ArmorItems:[{},{},{},{id:"minecraft:diamond_pickaxe",Count:1,tag:{Unbreakable:1,Damage:9}}]}
execute as @e[tag=wall,scores={wall_timer=-38..-9}] at @s run execute as @e[tag=wall_move,limit=1,sort=nearest,distance=..3] at @s run tp @s ~ ~-0.1 ~
execute as @e[tag=wall,scores={wall_timer=-7}] at @s run kill @e[tag=wall_move,sort=nearest,distance=..3]

execute as @e[tag=wall,scores={wall_timer=-18}] at @s run fill ~1 ~ ~ ~-1 ~ ~ air
execute as @e[tag=wall,scores={wall_timer=-28}] at @s run fill ~1 ~ ~ ~-1 ~1 ~ air






################################################################################ Gems ##############################################################################

execute as @e[tag=star1,nbt={HandItems:[{id:"minecraft:nether_star",Count:1b},{}]}] at @s run summon armor_stand 26 73.5 672 {NoGravity:1,Tags:["star_display","star_display1"],ArmorItems:[{},{},{},{id:"minecraft:nether_star",Count:1b}],Invisible:1}
execute as @e[tag=star1,nbt={HandItems:[{id:"minecraft:nether_star",Count:1b},{}]}] at @s run kill @s

execute as @e[tag=star2,nbt={HandItems:[{id:"minecraft:nether_star",Count:1b},{}]}] at @s run summon armor_stand 30 73.5 672 {NoGravity:1,Tags:["star_display","star_display2"],ArmorItems:[{},{},{},{id:"minecraft:nether_star",Count:1b}],Invisible:1}
execute as @e[tag=star2,nbt={HandItems:[{id:"minecraft:nether_star",Count:1b},{}]}] at @s run kill @s

execute as @e[tag=star] at @s run data merge entity @s {HandItems:[{},{}]}

execute if entity @e[tag=star_display1] if entity @e[tag=star_display2] run scoreboard players set @e[tag=sh,scores={gem_timer=0}] gem_timer 1

scoreboard players add @e[tag=sh] gem_timer 0
scoreboard players add @e[tag=sh,scores={gem_timer=1..}] gem_timer 1
scoreboard players set @e[tag=sh,scores={gem_timer=200..}] gem_timer 0

execute as @e[tag=sh,scores={gem_timer=2}] run playsound minecraft:gem_magic master @a 28 74 669 0.7 1 1

execute as @e[tag=sh,scores={gem_timer=2..20}] run execute as @e[tag=star_display1] at @s run tp @s ~ ~ ~ ~-4 ~
execute as @e[tag=sh,scores={gem_timer=2..20}] run execute as @e[tag=star_display2] at @s run tp @s ~ ~ ~ ~4 ~
execute as @e[tag=sh,scores={gem_timer=21..40}] run execute as @e[tag=star_display1] at @s run tp @s ~ ~ ~ ~-5 ~
execute as @e[tag=sh,scores={gem_timer=21..40}] run execute as @e[tag=star_display2] at @s run tp @s ~ ~ ~ ~5 ~
execute as @e[tag=sh,scores={gem_timer=41..120}] run execute as @e[tag=star_display1] at @s run tp @s ~ ~ ~ ~-6 ~
execute as @e[tag=sh,scores={gem_timer=41..120}] run execute as @e[tag=star_display2] at @s run tp @s ~ ~ ~ ~6 ~

execute as @e[tag=sh,scores={gem_timer=2..100}] run particle minecraft:enchant 28 75.5 669 2 -1.5 3 1 0 force
execute as @e[tag=sh,scores={gem_timer=2..100}] run particle minecraft:enchant 28 75.5 669 -2 -1.5 3 1 0 force
execute as @e[tag=sh,scores={gem_timer=12..100}] run particle minecraft:enchant 28 75 669 0.1 0.1 0.1 1 3 force
execute as @e[tag=sh,scores={gem_timer=32..80}] run particle minecraft:portal 28 74.5 669 0 0 0 1 3 force
execute as @e[tag=sh,scores={gem_timer=75..85}] run particle minecraft:smoke 28 74.5 669.8 0.2 0.1 0.2 0.03 5 force
execute as @e[tag=sh,scores={gem_timer=2..100}] run particle minecraft:mycelium 28 74.5 669 4 4 4 1 30 force
execute as @e[tag=sh,scores={gem_timer=80}] run particle minecraft:flame 28 74.5 669 0 0 0 0.15 30 force

execute as @e[tag=sh,scores={gem_timer=2}] run summon minecraft:armor_stand 28 74 669 {Tags:["ruby_display"],NoGravity:1,Rotation:[0f],Invisible:1,ShowArms:1}
execute as @e[tag=sh,scores={gem_timer=80}] run data merge entity @e[tag=ruby_display,limit=1] {HandItems:[{},{id:"minecraft:diamond_pickaxe",Count:1b,tag:{Damage:5,Unbreakable:1,HideFlags:63,display:{Name:'{"text":"Ruby"}'},Enchantments:[{}]}}]}
execute as @e[tag=sh,scores={gem_timer=100}] run kill @e[tag=star_display]

execute as @e[tag=sh,scores={gamestate=1}] run execute as @a[tag=trapped,nbt={Inventory:[{id:"minecraft:diamond_pickaxe",Count:1b,tag:{Unbreakable:1,Damage:5}}]}] at @s run scoreboard players set @e[tag=sh] boulder_timer 1
execute as @e[tag=sh,scores={gamestate=1}] run execute as @a[tag=trapped,nbt={Inventory:[{id:"minecraft:diamond_pickaxe",Count:1b,tag:{Unbreakable:1,Damage:5}}]}] at @s run scoreboard players set @e[tag=sh] gamestate 2


################################################################################ Reset ##############################################################################

execute as @a[x=47,y=61,z=718,distance=..2,tag=trapped] at @s run tp @s 28 63 723 180 0

execute as @a[x=28,y=63,z=723,distance=..5,tag=trapped] at @s run schedule function jungle_temple:reset 1


################################################################################ Vine Swing ##############################################################################
scoreboard players set @e[tag=swing] swing_speed 0
execute as @e[tag=swing] at @s run function jungle_temple:swing

execute as @e[tag=swing1] at @s positioned ^ ^-3.5 ^ run tp @e[tag=swing_seat1,limit=1] ~ ~ ~
execute as @e[tag=swing2] at @s positioned ^ ^-3.5 ^ run tp @e[tag=swing_seat2,limit=1] ~ ~ ~


execute as @a[scores={sneak=1..}] at @s run execute as @e[tag=swing_seat1,distance=..0.8] at @s run scoreboard players set @e[tag=swing1] swing_used 5
execute as @a[scores={sneak=1..}] at @s run execute as @e[tag=swing_seat2,distance=..0.8] at @s run scoreboard players set @e[tag=swing2] swing_used 5
execute as @a[scores={sneak=1..}] at @s run execute at @e[tag=swing_seat,distance=..0.8] run scoreboard players set @s was_swinging 10
execute as @a[scores={sneak=1..}] at @s run execute at @e[tag=swing_seat,distance=..0.8] run effect give @s levitation 1 255 true
scoreboard players remove @a was_swinging 1

scoreboard players remove @e[tag=swing] swing_used 1
scoreboard players set @e[tag=swing,scores={swing_used=1..}] is_moving 1
scoreboard players set @e[tag=swing,scores={swing_used=..0}] is_moving 0


scoreboard players add @e[tag=swing,scores={swing_used=4..}] swing_start 1
scoreboard players set @e[tag=swing,scores={swing_used=..3}] swing_start 0

scoreboard players set @e[tag=swing,scores={swing_rot=0,swing_used=..0}] swing_dir 1

execute as @e[tag=swing,scores={swing_start=1}] at @s run execute store result entity @s Rotation[0] float 1 run data get entity @p Rotation[0] 1

scoreboard players set @a[scores={sneak=1..}] sneak_exit 10
scoreboard players remove @a sneak_exit 1

execute as @a[scores={sneak=1..}] at @s run execute at @e[tag=swing_seat,distance=..0.8] run tp @s ~ ~ ~
execute as @a[scores={sneak_exit=8,was_swinging=1..}] at @s run effect clear @s levitation
execute as @a[scores={sneak_exit=8,was_swinging=1..}] at @s run effect give @s levitation 1 252 true
execute as @a[scores={sneak_exit=1,was_swinging=1..}] at @s run effect clear @s levitation
execute as @a[scores={sneak_exit=7,was_swinging=1..}] at @s run playsound jump master @a ~ ~ ~ 0.5 1.0
execute as @a[scores={sneak_exit=5..8,was_swinging=1..}] at @s run tp @s ^ ^ ^0.08
execute as @a[scores={sneak_exit=1..4,was_swinging=1..}] at @s run tp @s ^ ^ ^0.04


scoreboard players remove @e[tag=swing] swing_sound_cd 1
execute as @e[tag=swing,scores={swing_rot=-10..10,swing_sound_cd=..0,swing_dir=1,is_moving=1}] at @s run playsound swing1 master @a ~ ~ ~ 0.6 1.5
execute as @e[tag=swing,scores={swing_rot=-10..10,swing_sound_cd=..0,swing_dir=0,is_moving=1}] at @s run playsound swing2 master @a ~ ~ ~ 0.8 1.5
scoreboard players set @e[tag=swing,scores={swing_rot=-10..10,swing_sound_cd=..0,is_moving=1}] swing_sound_cd 10



execute as @e[tag=swing,scores={is_moving=1..}] at @s run execute store result score @s rot_change run data get entity @s Rotation[0] 1
execute as @e[tag=swing,scores={is_moving=1..}] at @s run execute store result score @s rot_player run data get entity @p[scores={was_swinging=1..}] Rotation[0] 1
execute as @e[tag=swing,scores={is_moving=1..}] at @s run scoreboard players operation @s rot_change -= @s rot_player
scoreboard players remove @e[tag=swing,scores={is_moving=1..,rot_change=181..}] rot_change 360
scoreboard players add @e[tag=swing,scores={is_moving=1..,rot_change=..-181}] rot_change 360
scoreboard players set @e[tag=swing,scores={is_moving=0}] rot_change 0

execute as @e[tag=swing,scores={swing_rot=-10..10,rot_change=..-10}] at @s run tp @s ~ ~ ~ ~2 ~
execute as @e[tag=swing,scores={swing_rot=-10..10,rot_change=10..}] at @s run tp @s ~ ~ ~ ~-2 ~


execute if block 32 78 683 stone_button[facing=east,powered=true] run scoreboard players set @e[tag=sh] pillar_timer 1

scoreboard players add @e[tag=sh,scores={pillar_timer=1..}] pillar_timer 1
scoreboard players set @e[tag=sh,scores={pillar_timer=50..}] pillar_timer 0
execute as @e[tag=sh,scores={pillar_timer=2}] at @s run execute as @e[tag=pillar] at @s run data merge entity @s {ArmorItems:[{},{},{},{id:"minecraft:diamond_pickaxe",Count:1,tag:{Unbreakable:1,Damage:8}}]}

execute as @e[tag=sh,scores={pillar_timer=2..}] at @s run setblock 41 68 680 air
execute as @e[tag=sh,scores={pillar_timer=2..41}] at @s run execute as @e[tag=pillar] at @s run tp @s ~ ~0.1 ~
execute as @e[tag=sh,scores={pillar_timer=44}] at @s run fill 41 68 680 41 72 680 polished_andesite
execute as @e[tag=sh,scores={pillar_timer=43}] at @s run kill @e[tag=pillar]
execute as @e[tag=sh,scores={pillar_timer=2}] at @s run setblock 32 78 683 air

execute as @e[tag=sh,scores={pillar_timer=2}] at @s run playsound minecraft:pillar master @a 41 71 680 1 0.8



################################################################################ Ladder Unlock ##############################################################################

execute if block 38 74 692 stone_button[powered=true] run scoreboard players add @e[tag=sh] ladder_unlock 1
execute if block 38 74 692 stone_button[powered=true] run particle firework 38 74.1 692 0 0 0 0.06 10 force
execute if block 38 74 692 stone_button[powered=true] run playsound magic master @a 38 74 692 1.0 1.0
execute if block 38 74 692 stone_button[powered=true] run setblock 38 74 692 air

execute if block 18 74 692 stone_button[powered=true] run scoreboard players add @e[tag=sh] ladder_unlock 1
execute if block 18 74 692 stone_button[powered=true] run particle firework 18 74.1 692 0 0 0 0.06 10 force
execute if block 18 74 692 stone_button[powered=true] run playsound magic master @a 18 74 692 1.0 1.0
execute if block 18 74 692 stone_button[powered=true] run setblock 18 74 692 air

execute as @e[tag=sh,scores={ladder_unlock=2..}] at @s run fill 28 79 686 28 73 686 acacia_wood
execute as @e[tag=sh,scores={ladder_unlock=2..}] at @s run fill 28 79 687 28 73 687 ladder[facing=south]
scoreboard players set @e[tag=sh,scores={ladder_unlock=2..,gamestate=2}] gamestate 3
scoreboard players set @e[tag=sh,scores={ladder_unlock=2..}] ladder_unlock 0



################################################################################ Door ##############################################################################

scoreboard players add @e[tag=sh] door_timer 0
scoreboard players add @e[tag=sh,scores={door_timer=1..}] door_timer 1
scoreboard players set @e[tag=sh,scores={door_timer=200..}] door_timer 0

execute as @e[tag=sh,scores={door_timer=2}] run summon minecraft:armor_stand 27.4 75 701 {Tags:["wall","wall_right"],NoGravity:1,Rotation:[90f],Invisible:1}
execute as @e[tag=sh,scores={door_timer=2}] run summon minecraft:armor_stand 29.6 75 701 {Tags:["wall","wall_left"],NoGravity:1,Rotation:[90f],Invisible:1}

execute as @e[tag=sh,scores={door_timer=3}] run execute as @e[tag=wall_right] at @s run data merge entity @s {ArmorItems:[{},{},{},{id:"minecraft:diamond_pickaxe",Count:1,tag:{Unbreakable:1,Damage:4}}]}
execute as @e[tag=sh,scores={door_timer=3}] run execute as @e[tag=wall_left] at @s run data merge entity @s {ArmorItems:[{},{},{},{id:"minecraft:diamond_pickaxe",Count:1,tag:{Unbreakable:1,Damage:3}}]}
execute as @e[tag=sh,scores={door_timer=40..55}] run execute as @e[tag=wall_right] at @s run tp @s ~0.1 ~ ~
execute as @e[tag=sh,scores={door_timer=40..55}] run execute as @e[tag=wall_left] at @s run tp @s ~-0.1 ~ ~
execute as @e[tag=sh,scores={door_timer=57}] run kill @e[tag=wall,x=28,y=73,z=700,distance=..5]
execute as @e[tag=sh,scores={door_timer=58}] run fill 27 74 701 29 78 701 minecraft:andesite

scoreboard players set @e[tag=sh,scores={door_timer=4}] door_timer 35

execute as @e[tag=sh,scores={door_timer=36}] run playsound minecraft:door_open master @a 28 75 701 1 0.8


############################################################################# BOULDER #################################################################################

execute as @e[tag=sh,scores={boulder_timer=125}] run tag @a[tag=trapped,x=32,y=73,z=668,distance=..5] add dead
execute as @e[tag=sh,scores={boulder_timer=125}] run tag @a[tag=trapped,x=22,y=73,z=667,distance=..5] add dead
execute as @e[tag=sh,scores={boulder_timer=125}] run tag @a[tag=trapped,x=28,y=73,z=672,distance=..5] add dead
execute as @e[tag=sh,scores={boulder_timer=200}] run tag @a[tag=trapped,x=28,y=73,z=700,distance=..4] add dead
execute as @e[tag=sh,scores={boulder_timer=100..290}] run execute at @e[tag=boulder] run tag @a[tag=trapped,distance=..3] add dead

execute as @a[tag=dead] at @s run kill @e[tag=boulder]
execute as @a[tag=dead] at @s run clear @s diamond_pickaxe
execute as @a[tag=dead] at @s run kill @s
tag @a[tag=dead] remove dead

execute as @e[tag=sh,scores={boulder_timer=120}] run playsound stone_roll master @a ~ ~ ~ 100.0 0.8 1

execute as @e[tag=sh,scores={boulder_timer=2}] run fill 25 77 697 25 73 694 minecraft:air
execute as @e[tag=sh,scores={boulder_timer=2}] run fill 31 77 697 31 73 694 minecraft:air

scoreboard players set @e[tag=sh,scores={boulder_timer=2}] boulder_timer 90

scoreboard players add @e[tag=boulder] boulder_rot 9
scoreboard players remove @e[tag=boulder,scores={boulder_rot=360..}] boulder_rot 360
execute as @e[tag=boulder] at @s run execute store result entity @s Pose.Head[0] float 1 run scoreboard players get @s boulder_rot

scoreboard players add @e[tag=sh] boulder_timer 0
scoreboard players add @e[tag=sh,scores={boulder_timer=1..}] boulder_timer 1
scoreboard players set @e[tag=sh,scores={boulder_timer=400..}] boulder_timer 0

execute as @e[tag=sh,scores={boulder_timer=102}] run summon minecraft:armor_stand 28 82 672 {Tags:[boulder],ArmorItems:[{},{},{},{id:"minecraft:diamond_pickaxe",Count:1,tag:{Unbreakable:1,Damage:1}}],Pose:{Head:[0.001f,0.001f,0.001f]}}
execute as @e[tag=sh,scores={boulder_timer=120..200}] run execute as @e[tag=boulder] at @s run tp @s ~ ~ ~0.295

execute as @e[tag=sh,scores={boulder_timer=200}] if entity @a[tag=trapped,x=20,y=72,z=696,distance=..7] run tag @e[tag=boulder,tag=!b_left] add b_right
execute as @e[tag=sh,scores={boulder_timer=200}] if entity @a[tag=trapped,x=34,y=72,z=696,distance=..7] run tag @e[tag=boulder,tag=!b_right] add b_left
execute as @e[tag=sh,scores={boulder_timer=200}] if entity @a[tag=trapped,x=10,y=72,z=696,distance=..10] run tag @e[tag=boulder,tag=!b_left] add b_right
execute as @e[tag=sh,scores={boulder_timer=200}] if entity @a[tag=trapped,x=44,y=72,z=696,distance=..10] run tag @e[tag=boulder,tag=!b_right] add b_left


execute as @e[tag=sh,scores={boulder_timer=198}] run execute as @e[tag=b_right] at @s run data merge entity @s {Pose:{Head:[0.001f,15.001f,0.1f]}}
execute as @e[tag=sh,scores={boulder_timer=198}] run execute as @e[tag=b_left] at @s run data merge entity @s {Pose:{Head:[0.001f,-15.001f,0.1f]}}

execute as @e[tag=sh,scores={boulder_timer=199}] run execute as @e[tag=b_right] at @s run data merge entity @s {Pose:{Head:[0.001f,30.001f,0.1f]}}
execute as @e[tag=sh,scores={boulder_timer=199}] run execute as @e[tag=b_left] at @s run data merge entity @s {Pose:{Head:[0.001f,-30.001f,0.1f]}}

execute as @e[tag=sh,scores={boulder_timer=200}] run execute as @e[tag=b_right] at @s run data merge entity @s {Pose:{Head:[0.001f,45.001f,0.1f]}}
execute as @e[tag=sh,scores={boulder_timer=200}] run execute as @e[tag=b_left] at @s run data merge entity @s {Pose:{Head:[0.001f,-45.001f,0.1f]}}

execute as @e[tag=sh,scores={boulder_timer=201}] run execute as @e[tag=b_right] at @s run data merge entity @s {Pose:{Head:[0.001f,60.001f,0.1f]}}
execute as @e[tag=sh,scores={boulder_timer=201}] run execute as @e[tag=b_left] at @s run data merge entity @s {Pose:{Head:[0.001f,-60.001f,0.1f]}}

execute as @e[tag=sh,scores={boulder_timer=202}] run execute as @e[tag=b_right] at @s run data merge entity @s {Pose:{Head:[0.001f,75.001f,0.1f]}}
execute as @e[tag=sh,scores={boulder_timer=202}] run execute as @e[tag=b_left] at @s run data merge entity @s {Pose:{Head:[0.001f,-75.001f,0.1f]}}

execute as @e[tag=sh,scores={boulder_timer=203}] run execute as @e[tag=b_right] at @s run data merge entity @s {Pose:{Head:[0.001f,90.001f,0.1f]}}
execute as @e[tag=sh,scores={boulder_timer=203}] run execute as @e[tag=b_left] at @s run data merge entity @s {Pose:{Head:[0.001f,-90.001f,0.1f]}}

execute as @e[tag=sh,scores={boulder_timer=201..283}] run execute as @e[tag=b_right] at @s run tp @s ~-0.3 ~ ~
execute as @e[tag=sh,scores={boulder_timer=201..283}] run execute as @e[tag=b_left] at @s run tp @s ~0.3 ~ ~

execute as @e[tag=sh,scores={boulder_timer=283}] run execute as @e[tag=b_right] at @s run particle block cobblestone 4 75 696 1 1 2 0.1 30
execute as @e[tag=sh,scores={boulder_timer=283}] run execute as @e[tag=b_left] at @s run particle block cobblestone 52 75 696 1 1 2 0.1 30
execute as @e[tag=sh,scores={boulder_timer=283}] run execute as @e[tag=b_right] at @s run particle large_smoke 4 75 696 1 1 1 0.1 10
execute as @e[tag=sh,scores={boulder_timer=283}] run execute as @e[tag=b_left] at @s run particle large_smoke 52 75 696 1 1 1 0.1 10

execute as @e[tag=sh,scores={boulder_timer=284}] run kill @e[tag=boulder]

execute as @e[tag=boulder] at @s run particle block cobblestone ~ ~1 ~ 2 2 2 0.1 2

##############################################################################################################################################################

tag @a remove give
scoreboard players set @a rc 0
scoreboard players set @a sneak 0
scoreboard players set @a jump 0
scoreboard players set @a walk 0
scoreboard players set @a sprint 0
