Tracking item display
Hello,
Before I get into it, the question here is "how do I make this item display face the nearest targeted entity."
Now for the meat.
I am making a spell system and one of my casting types is called an Orb.
The way an orb works is that it is placed in the position it is summoned and it is supposed to target the nearest entity that is not itself, nor the player that summons it.
After a bit of time, the orb will fire a raycast in the direction that it is facing with the intent of hitting the target it is facing.
I have done tests with other item displays and got them to track entities just fine and it is really cool to watch them turn to face them, but the code stopped working when I added the exclusion for if the nearest entity is the player who casts it.
The code I have is as follows:
Continue to help posttag @s add orb_active execute as @s[tag=on_entities] at @s as @e[type=!interaction,type=!item_display,distance=..32,tag=!orb_active,sort=nearest] unless score @s player_id = @e[tag=orb_active,limit=1,sort=nearest] player_id facing entity @s eyes as @e[tag=orb_active] run tp @s ~ ~ ~ ~ ~ tag @s remove orb_active
So the way that I interpret this block is this:
1) The orb active tag is put on the orb entity.
2) Execute as the orb which has the tag "on_entities" at where the orb is, as all entities within 32 blocks except for itself and interaction entities unless that entity's player_id score is the same as the active orb's player_id score, face the eyes as the active orb and teleport to face the relative position defined previously.
3) The orb active tag is removed from the orb entity.
The orb entity is not turning to face the target entity, so I am thinking there is an issue with the way that I have the: facing entity @s eyes as @e[tag=orb_active] run tp @s ~ ~ ~ ~ ~
portion of the code.
Maybe I have to be running the facing entity as the orb instead of the target entity, but if so I'll have to run the selector for the target again.
Any tips on how to make this work?