From 159d614a3a7a56818b561f79ec2c0b1eb00440a0 Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Thu, 11 Apr 2013 18:10:24 -0500 Subject: [PATCH] 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. --- src/main/java/net/minecraft/server/EntityTracker.java | 4 ++-- .../java/net/minecraft/server/EntityTrackerEntry.java | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/minecraft/server/EntityTracker.java b/src/main/java/net/minecraft/server/EntityTracker.java index 4de1273206..9e2b76f896 100644 --- a/src/main/java/net/minecraft/server/EntityTracker.java +++ b/src/main/java/net/minecraft/server/EntityTracker.java @@ -56,9 +56,9 @@ public class EntityTracker { } else if (entity instanceof EntityItem) { this.addEntity(entity, 64, 20, true); } 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) { - 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) { this.addEntity(entity, 64, 3, true); } else if (entity instanceof EntityWither) { diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java index 4871bd7301..65cc4e8422 100644 --- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java +++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java @@ -68,7 +68,7 @@ public class EntityTrackerEntry { 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.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)); } - 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)); + } 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) { for (int i = 0; i < 5; ++i) {