Started by
PIGLIN98
on
Topic category: Help with Minecraft modding (Java Edition)
I dont really have idea on how to do it. I never seen procedure blocks to even work with crosshairs in general. My goal is to just detect if the crosshair is looking directly at the entity
Edited by PIGLIN98 on Thu, 04/24/2025 - 23:11
there are raytracing blocks, you can combine with "does entity exist at xyz".
you can use a while loop at player tick update, with a local number variable, that starts with 1, and keeps increasing by 1, with every repeat, untill the variable reaches the maximum range you set.
the loop checks: does entity exist at (look xyz position of eventtargetentity with raytrace distance of "local variable") in square cube size 1 of type "living entity".
If yes, set another local entity variable to store the entity for further use, then break out of loop,
if no, check if block at that location is solid, if yes, break out of loop, if that is also false, increase local number variable by 1.
then if local entity variable is living entity, do whatever the procedure is supposed to do.