net.minecraft.entity uses an AtomicInteger to set an entity's id in the constructor. However, this AtomicInteger is also incremented by the client rendering thread when a new entity is created. Due to multi-threading of rendering and integrated server this causes inconsistent behavior when compared with a dedicated server and connected client.
This issue can by solved by either not incrementing the CURRENT_ID AtomicInteger when an entity is created by the rendering thread, or by giving the client and server separate counters, as is the case with a dedicated server and client.
https://youtu.be/hr-twzxs6FM highlights why the entity id matters and the inconsistency between integrated and dedicated servers.
Comments 6
There is some code discussion in this follow-up video.
An inconsistency like this in behaviour between single-player and multiplayer worlds shouldn't exist!
I support the resolution of this bug.
This bug needs to be fixxed!