Description
There is a synchronization issue with the EnderDragonPart entity IDs between the server and client. Specifically, the ID of the entity parts on the client is one less than on the server. This discrepancy leads to desynchronization when hitting the dragon, causing the server to register a hit on a different part of the Ender Dragon than the client perceives.
How to reproduce
1. Freeze the game /tick freeze
2. Summon an ender dragon /summon minecraft:ender_dragon
3. Step two ticks /tick step 2
4. Disable the ender dragon ai /data merge entity @n[type=minecraft:ender_dragon] {NoAI:1b}
5. Unfreeze the game /tick unfreeze
Observe how hitting the neck with a netherite sword increases the damage, while hitting every other part of the dragon does not.
Observe how hitting certain parts of the dragon are not registered on the server side.
Adding a debug statement in the hurt function of the EnderDragonPart reveals that the server and client disagree on which part was hit.
Expected behaviour
As the code indicates, only hitting the head should increase damage.
All hits should be registered on the server side.
The server and client should not disagree on which part was hit.
Technical Details
The issue lies within the recreateFromPacket
function in the EnderDragon
class. In this function, the first dragon part in the subEntities
list gets assigned the same ID as the dragon itself, instead of being assigned the ID of the dragon plus one. Similarly, all subsequent part IDs are off by one on the client side as well.
Linked issues
Comments

Please provide steps to reproduce this bug, as well as expected and observed behaviour.
In particular, please describe what impact this has on vanilla gameplay outside of MC-158205, if any.
This issue is being temporarily resolved as Awaiting Response. Once the requested information has been delivered, the report will be reopened automatically.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki
The fact that MC-158205 is caused by entity ID desync is already mentioned there; I'll add it to the description directly as well. Since this has no other vanilla impact than that bug I'll go ahead and close this as a duplicate, but I'll expand the description of that bug report a bit.

There is the vanilla impact of the wrong entity parts having increased damage when hit, which I don't think is mentioned in MC-158205. That should probably be added too. Also, adding info about this being an off-by-one error in the for
loop of the recreateFromPacket
function in the EnderDragon
class is probably helpful for the devs.
This is part of the problem that causes MC-158205, but is still a sperate issue since a distance check in
ServerGamePacketListenerImplMixin
is also relevant for MC-158205