Ender dragons' rotation value and visual rotation do not match, it is visually rotated 180 degrees.
Steps to reproduce:
Spawn an ender dragon.
/summon ender_dragon
Option 1:
Run the following command in a repeating command block:
/execute at @p as @e[type=ender_dragon] run tp @s ^ ^ ^20 facing ^ ^ ^-20
Observe the dragon faces away from you.
Option 2:
Run the following command in a repeating command block:
/execute as @p at @e[type=ender_dragon] positioned ^ ^ ^10 facing entity @e[type=ender_dragon,c=1] feet run tp @s ~ ~ ~
Observe you're put behind the dragon
Option 3:
Run the following command in a repeating command block:
/execute as @p at @e[type=ender_dragon] run tp @s ~ ~ ~ ~ ~
Observe you're facing the opposite direction from the dragon at all times.
The dragon faces the exact opposite direction, being visually rotated 180 degrees compared to the rotation value; this messes up commands which use the local coordinates.
This report is an edited copy of the java edition equivalent: MC-135115.
Thank you for your report!
After consideration, the issue is being closed as Won't Fix.
Please note that this is not the same as Working as Intended, as this bug report correctly describes behavior in the game that might not be the intended or desirable behavior, but it will not be fixed right now. Sometimes, this is because the issue reported is minor and/or impossible to change without large architectural changes to the code base.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki