Ender dragons exhibit a behavior where they do not target the player they intend to attack, which differs from the behavior of most other mobs. This issue is related to MC-269192, MC-264456, and MC-263315.
Steps to replicate
Enter the End realm
Respawn the ender dragon if it has already been defeated
Paste the following command in a repeating activated command block:
execute as @e[type=minecraft:ender_dragon] on target run say I will be attacked be the ender dragon
Switch to survival mode
Observed results: The ender dragon consistently fails to target you, as evidenced by the absence of messages from the say command even during attacks.
Expected behavior: The ender dragon should target you, triggering messages from the say command accordingly.
Confirmed for 1.20.4.