Correct vehicle movement issues. Fixes BUKKIT-2993, BUKKIT-4056

When a player comes into range of an entity in a vehicle they will often be
sent the spawn packet for the rider before receiving one for the vehicle.
This causes the attachment packet to fail client side because it attempts
to attach the rider to a vehicle that doesn't exist on the client. To
correct this we account for both possible orderings and send the
attachment packet appropriately.

Vanilla also sends an new attach packet every 60 ticks even if the vehicle
has not changed. As this packet is a toggle this resulting in players
teleporting around randomly. Since we handle attachments properly now we
simply revert this section to use the 1.4 logic.
This commit is contained in:
Travis Watkins 2013-04-11 18:10:24 -05:00 committed by Wesley Wolfe
parent ce5b97ea83
commit 159d614a3a
2 changed files with 8 additions and 4 deletions

View File

@ -56,9 +56,9 @@ public class EntityTracker {
} else if (entity instanceof EntityItem) { } else if (entity instanceof EntityItem) {
this.addEntity(entity, 64, 20, true); this.addEntity(entity, 64, 20, true);
} else if (entity instanceof EntityMinecartAbstract) { } else if (entity instanceof EntityMinecartAbstract) {
this.addEntity(entity, 80, 3, true); this.addEntity(entity, 80, 2, true); // CraftBukkit - Send updates at same rate as players
} else if (entity instanceof EntityBoat) { } else if (entity instanceof EntityBoat) {
this.addEntity(entity, 80, 3, true); this.addEntity(entity, 80, 2, true); // CraftBukkit - Send updates at same rate as players
} else if (entity instanceof EntitySquid) { } else if (entity instanceof EntitySquid) {
this.addEntity(entity, 64, 3, true); this.addEntity(entity, 64, 3, true);
} else if (entity instanceof EntityWither) { } else if (entity instanceof EntityWither) {

View File

@ -68,7 +68,7 @@ public class EntityTrackerEntry {
this.scanPlayers(list); this.scanPlayers(list);
} }
if (this.v != this.tracker.vehicle || this.tracker.vehicle != null && this.m % 60 == 0) { if (this.v != this.tracker.vehicle /* || this.tracker.vehicle != null && this.m % 60 == 0 */) { // CraftBukkit - Revert to 1.4 logic, this packet is a toggle
this.v = this.tracker.vehicle; this.v = this.tracker.vehicle;
this.broadcast(new Packet39AttachEntity(this.tracker, this.tracker.vehicle)); this.broadcast(new Packet39AttachEntity(this.tracker, this.tracker.vehicle));
} }
@ -318,9 +318,13 @@ public class EntityTrackerEntry {
entityplayer.playerConnection.sendPacket(new Packet28EntityVelocity(this.tracker.id, this.tracker.motX, this.tracker.motY, this.tracker.motZ)); entityplayer.playerConnection.sendPacket(new Packet28EntityVelocity(this.tracker.id, this.tracker.motX, this.tracker.motY, this.tracker.motZ));
} }
if (this.tracker.vehicle != null) { // CraftBukkit start
if (this.tracker.vehicle != null && this.tracker.id > this.tracker.vehicle.id) {
entityplayer.playerConnection.sendPacket(new Packet39AttachEntity(this.tracker, this.tracker.vehicle)); entityplayer.playerConnection.sendPacket(new Packet39AttachEntity(this.tracker, this.tracker.vehicle));
} else if (this.tracker.passenger != null && this.tracker.id > this.tracker.passenger.id) {
entityplayer.playerConnection.sendPacket(new Packet39AttachEntity(this.tracker.passenger, this.tracker));
} }
// CraftBukkit end
if (this.tracker instanceof EntityLiving) { if (this.tracker instanceof EntityLiving) {
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {