Bukkit/CraftBukkit — pull request #933 by mrapple (2012-11-20 03:09:25+00:00)
Title: Fix players not getting correctly attached to entities

Often times when the EntityTracker is spawning entities for a player because they have entered that player's visible area, it will sometimes spawn the player first and sometimes spawn the vehicle first.

Situation 1:
Player A (ID 11) and Player B (ID 12) are both out of viewing range
Player A gets in a boat (ID 13) and starts sailing towards Player B
Player A comes into the visible range of Player B
EntityTracker tells Player B to:
1. Spawn Player A (lowest ID)
2. Attach Player A to boat
3. Spawn the boat

To fix this situation, we have to check to see if the boat has a passenger first, instead of checking if the player has a vehicle.

Situation 2:
Player B (ID 11) spawns a boat (ID 12)
Player A (ID 13) gets in the boat
Player A moves out of viewing range of Player B, then back in
EntityTracker tells player B to:
1. Spawn the boat (lowest ID)
2. Attach Player A to the boat
3. Spawn Player A

To fix this situation, we have to check to see if the player has a vehicle fist, instead of checking if the boat has a passenger.

In order to fix both issues, we need to make sure we're accounting for both cases. Because the client doesn't validate Packet39AttachEntity or care if the entity given doesn't exist, sending an extra packet is harmless.