## Run from tf_raycast:start_raycast

# Using dx for precise hitbox detection
# Parameters:
#     Edit not_mob.json in tags/entities to change which entities will not be targetted
#     Change the "positioned" offsets to change projectile size
#       - If > 1 block, just use one dx detection
execute as @e[tag=!raycasting,type=!#spider_queen:not_mob,dx=0] positioned ~-0.99 ~-0.99 ~-0.99 if entity @s[dx=0] positioned ~0.99 ~0.99 ~0.99 run function spider_queen:collide

scoreboard players add .distance webcast 1

# Make raycast visible
particle minecraft:block cobweb ~ ~ ~

# Repeat the raycast if certain conditions are met
# Parameters:
#    (score after "matches") * (accuracy increment) = range
#    The "positioned" value specifies the precision
#    Edit raycast_pass.json in tags/blocks to change which blocks the raycast ignores
#    "rotated" controls arc/curve of raycast path
execute if score .distance webcast matches ..1000 positioned ^ ^ ^0.05 rotated ~ ~ unless block ~ ~ ~ #spider_queen:raycast_pass run fill ^ ^ ^-0.1 ~ ~ ~-0.2 cobweb replace #spider_queen:raycast_pass
execute if score .distance webcast matches ..1000 positioned ^ ^ ^0.05 rotated ~ ~ if block ~ ~ ~ #spider_queen:raycast_pass run function spider_queen:raycast
