2019-01-01 03:15:55 +00:00
|
|
|
From 99e8159915dbca4b04eac59a3ebe3cb845b70f15 Mon Sep 17 00:00:00 2001
|
2015-07-23 11:13:26 +00:00
|
|
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
2016-02-29 23:09:49 +00:00
|
|
|
Date: Wed, 2 Mar 2016 23:13:07 -0600
|
2015-07-23 11:13:26 +00:00
|
|
|
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
|
2019-01-01 03:15:55 +00:00
|
|
|
index dd6c84b4a..a12a42c32 100644
|
2015-07-23 11:13:26 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
2018-10-11 03:18:02 +00:00
|
|
|
@@ -41,7 +41,19 @@ public class EntityTrackerEntry {
|
2015-12-23 03:55:00 +00:00
|
|
|
private boolean x;
|
2015-07-23 11:13:26 +00:00
|
|
|
private boolean y;
|
2016-02-29 23:09:49 +00:00
|
|
|
public boolean b;
|
2016-06-09 03:57:14 +00:00
|
|
|
- public final Set<EntityPlayer> trackedPlayers = Sets.newHashSet();
|
2016-02-29 23:09:49 +00:00
|
|
|
+ // Paper start
|
2015-12-23 03:55:00 +00:00
|
|
|
+ // Replace trackedPlayers Set with a Map. The value is true until the player receives
|
|
|
|
+ // their first update (which is forced to have absolute coordinates), false afterward.
|
|
|
|
+ public java.util.Map<EntityPlayer, Boolean> trackedPlayerMap = new java.util.HashMap<EntityPlayer, Boolean>();
|
|
|
|
+ public Set<EntityPlayer> trackedPlayers = trackedPlayerMap.keySet();
|
2018-10-11 03:18:02 +00:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Requested in https://github.com/PaperMC/Paper/issues/1537 to allow intercepting packets
|
|
|
|
+ */
|
|
|
|
+ public void sendPlayerPacket(EntityPlayer player, Packet packet) {
|
|
|
|
+ player.playerConnection.sendPacket(packet);
|
|
|
|
+ }
|
2016-02-29 23:09:49 +00:00
|
|
|
+ // Paper end
|
2015-07-23 11:13:26 +00:00
|
|
|
|
2016-02-29 23:09:49 +00:00
|
|
|
public EntityTrackerEntry(Entity entity, int i, int j, int k, boolean flag) {
|
2015-07-23 11:13:26 +00:00
|
|
|
this.tracker = entity;
|
2018-10-11 03:18:02 +00:00
|
|
|
@@ -142,6 +154,7 @@ public class EntityTrackerEntry {
|
2016-06-09 03:57:14 +00:00
|
|
|
boolean flag1 = l1 * l1 + i2 * i2 + j2 * j2 >= 128L || this.a % 60 == 0;
|
|
|
|
boolean flag2 = Math.abs(j1 - this.yRot) >= 1 || Math.abs(k1 - this.xRot) >= 1;
|
2015-07-23 11:13:26 +00:00
|
|
|
|
2016-02-29 23:09:49 +00:00
|
|
|
+ if (this.a > 0 || this.tracker instanceof EntityArrow) { // Paper - Moved up
|
2016-06-09 03:57:14 +00:00
|
|
|
// CraftBukkit start - Code moved from below
|
|
|
|
if (flag1) {
|
|
|
|
this.xLoc = k;
|
2018-10-11 03:18:02 +00:00
|
|
|
@@ -155,7 +168,6 @@ public class EntityTrackerEntry {
|
2016-06-09 03:57:14 +00:00
|
|
|
}
|
2016-02-29 23:09:49 +00:00
|
|
|
// CraftBukkit end
|
2016-06-09 03:57:14 +00:00
|
|
|
|
2016-02-29 23:09:49 +00:00
|
|
|
- if (this.a > 0 || this.tracker instanceof EntityArrow) {
|
2016-06-09 03:57:14 +00:00
|
|
|
if (l1 >= -32768L && l1 < 32768L && i2 >= -32768L && i2 < 32768L && j2 >= -32768L && j2 < 32768L && this.v <= 400 && !this.x && this.y == this.tracker.onGround) {
|
|
|
|
if ((!flag1 || !flag2) && !(this.tracker instanceof EntityArrow)) {
|
|
|
|
if (flag1) {
|
2019-01-01 03:15:55 +00:00
|
|
|
@@ -202,6 +214,26 @@ public class EntityTrackerEntry {
|
2015-07-23 11:13:26 +00:00
|
|
|
|
2019-01-01 03:15:55 +00:00
|
|
|
if (packet1 != null) {
|
|
|
|
this.broadcast((Packet) packet1);
|
2016-02-29 23:09:49 +00:00
|
|
|
+ // Paper start - ensure fresh viewers get an absolute position on their first update,
|
2015-07-23 11:13:26 +00:00
|
|
|
+ // since we can't be certain what position they received in the spawn packet.
|
2019-01-01 03:15:55 +00:00
|
|
|
+ if (packet1 instanceof PacketPlayOutEntityTeleport) {
|
|
|
|
+ this.broadcast((Packet) packet1);
|
2015-07-23 11:13:26 +00:00
|
|
|
+ } else {
|
2015-12-23 03:55:00 +00:00
|
|
|
+ PacketPlayOutEntityTeleport teleportPacket = null;
|
2015-07-23 11:13:26 +00:00
|
|
|
+
|
2015-12-23 03:55:00 +00:00
|
|
|
+ for (java.util.Map.Entry<EntityPlayer, Boolean> viewer : trackedPlayerMap.entrySet()) {
|
|
|
|
+ if (viewer.getValue()) {
|
|
|
|
+ viewer.setValue(false);
|
|
|
|
+ if (teleportPacket == null) {
|
2016-02-29 23:09:49 +00:00
|
|
|
+ teleportPacket = new PacketPlayOutEntityTeleport(this.tracker);
|
2015-12-23 03:55:00 +00:00
|
|
|
+ }
|
2018-10-11 03:18:02 +00:00
|
|
|
+ sendPlayerPacket(viewer.getKey(), teleportPacket);
|
2015-07-23 11:13:26 +00:00
|
|
|
+ } else {
|
2019-01-01 03:15:55 +00:00
|
|
|
+ sendPlayerPacket(viewer.getKey(), (Packet) packet1);
|
2015-07-23 11:13:26 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2016-02-29 23:09:49 +00:00
|
|
|
+ // Paper end
|
2015-07-23 11:13:26 +00:00
|
|
|
}
|
|
|
|
|
2016-02-29 23:09:49 +00:00
|
|
|
this.d();
|
2019-01-01 03:15:55 +00:00
|
|
|
@@ -338,7 +370,7 @@ public class EntityTrackerEntry {
|
2015-07-23 11:13:26 +00:00
|
|
|
|
|
|
|
entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId()));
|
|
|
|
// CraftBukkit end
|
2015-12-23 03:55:00 +00:00
|
|
|
- this.trackedPlayers.add(entityplayer);
|
2016-02-29 23:09:49 +00:00
|
|
|
+ this.trackedPlayerMap.put(entityplayer, true); // Paper
|
2019-01-01 03:15:55 +00:00
|
|
|
Packet<?> packet = this.e();
|
2015-07-23 11:13:26 +00:00
|
|
|
|
2015-12-23 03:55:00 +00:00
|
|
|
entityplayer.playerConnection.sendPacket(packet);
|
2015-07-23 11:13:26 +00:00
|
|
|
--
|
2019-01-01 03:15:55 +00:00
|
|
|
2.20.1
|
2015-07-23 11:13:26 +00:00
|
|
|
|