From 579868e0c17f3f228bf59712818cc895a216dfdd Mon Sep 17 00:00:00 2001 From: Jedediah Smith Date: Thu, 23 Jul 2015 04:13:26 -0700 Subject: [PATCH] Send absolute position the first time an entity is seen --- ...sition-the-first-time-an-entity-is-s.patch | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Spigot-Server-Patches/0066-Send-absolute-position-the-first-time-an-entity-is-s.patch diff --git a/Spigot-Server-Patches/0066-Send-absolute-position-the-first-time-an-entity-is-s.patch b/Spigot-Server-Patches/0066-Send-absolute-position-the-first-time-an-entity-is-s.patch new file mode 100644 index 0000000..6e63116 --- /dev/null +++ b/Spigot-Server-Patches/0066-Send-absolute-position-the-first-time-an-entity-is-s.patch @@ -0,0 +1,88 @@ +From 9cb32ededdc1ae3b2d844daabab50b0e844a96ce Mon Sep 17 00:00:00 2001 +From: Jedediah Smith +Date: Fri, 3 Apr 2015 17:26:21 -0400 +Subject: [PATCH] Send absolute position the first time an entity is seen + + +diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java +index f0149bf..b77de55 100644 +--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java ++++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java +@@ -40,6 +40,7 @@ public class EntityTrackerEntry { + private boolean y; + public boolean n; + public Set trackedPlayers = Sets.newHashSet(); ++ public Set freshViewers = Sets.newHashSet(); // PaperSpigot + + public EntityTrackerEntry(Entity entity, int i, int j, boolean flag) { + this.tracker = entity; +@@ -121,20 +122,20 @@ public class EntityTrackerEntry { + boolean flag = Math.abs(j1) >= 4 || Math.abs(k1) >= 4 || Math.abs(l1) >= 4 || this.m % 60 == 0; + boolean flag1 = Math.abs(l - this.yRot) >= 4 || Math.abs(i1 - this.xRot) >= 4; + +- // CraftBukkit start - Code moved from below +- if (flag) { +- this.xLoc = i; +- this.yLoc = j; +- this.zLoc = k; +- } ++ if (this.m > 0 || this.tracker instanceof EntityArrow) { // PaperSpigot - Move up ++ // CraftBukkit start - Code moved from below ++ if (flag) { ++ this.xLoc = i; ++ this.yLoc = j; ++ this.zLoc = k; ++ } + +- if (flag1) { +- this.yRot = l; +- this.xRot = i1; +- } +- // CraftBukkit end ++ if (flag1) { ++ this.yRot = l; ++ this.xRot = i1; ++ } ++ // CraftBukkit end + +- if (this.m > 0 || this.tracker instanceof EntityArrow) { + if (j1 >= -128 && j1 < 128 && k1 >= -128 && k1 < 128 && l1 >= -128 && l1 < 128 && this.v <= 400 && !this.x && this.y == this.tracker.onGround) { + if ((!flag || !flag1) && !(this.tracker instanceof EntityArrow)) { + if (flag) { +@@ -173,7 +174,24 @@ public class EntityTrackerEntry { + } + + if (object != null) { +- this.broadcast((Packet) object); ++ // PaperSpigot start - ensure fresh viewers get an absolute position on their first update, ++ // since we can't be certain what position they received in the spawn packet. ++ if (object instanceof PacketPlayOutEntityTeleport) { ++ this.broadcast((Packet) object); ++ } else { ++ PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this.tracker.getId(), i, j, k, (byte) l, (byte) i1, this.tracker.onGround); ++ ++ for (EntityPlayer viewer : (Set) this.trackedPlayers) { ++ if (this.freshViewers.contains(viewer)) { ++ viewer.playerConnection.sendPacket(teleportPacket); ++ } else { ++ viewer.playerConnection.sendPacket((Packet) object); ++ } ++ } ++ } ++ ++ this.freshViewers.clear(); ++ // PaperSpigot end + } + + this.b(); +@@ -324,6 +342,7 @@ public class EntityTrackerEntry { + + entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId())); + // CraftBukkit end ++ this.freshViewers.add(entityplayer); // PaperSpigot + this.trackedPlayers.add(entityplayer); + Packet packet = this.c(); + +-- +1.9.5.msysgit.1 +