execute as @e[tag=cryshat] at @p[predicate=survivalplus:crystalhat] run tp @s ~ ~2.3 ~
execute positioned ~ ~-2.3 ~ unless entity @a[predicate=survivalplus:crystalhat,distance=..1] run kill @s

execute store result score @s itemcount if entity @e[tag=cryshat,distance=...1]
execute if score @s itemcount matches 2.. run function survivalplus:tools/trap/hatcrysfix

tp @s ~ ~ ~ ~3 ~3
execute if entity @s[nbt={Rotation:[90f]}] at @s run tp @s ~ ~ ~ ~ ~-90
execute if entity @e[predicate=survivalplus:targeted,distance=..6,type=!zombie_villager,tag=!merchant_face] anchored eyes run tp @s ~ ~ ~ facing entity @e[predicate=survivalplus:targeted,type=!zombie_villager,tag=!merchant_face,limit=1,sort=nearest] eyes
execute if entity @e[predicate=survivalplus:targeted,distance=..6,type=!zombie_villager,tag=!merchant_face] if score @s timer matches 0 run function survivalplus:tools/trap/crystarget

execute unless score @s timer matches 1.. run scoreboard players set @s timer 30
execute if entity @e[predicate=survivalplus:targeted,distance=..6,type=!zombie_villager,tag=!merchant_face] run scoreboard players remove @s[scores={timer=1..}] timer 1