Use a method for EntityTrackerEntry for Gerrygames

Allow overriding the method for interception

https://github.com/PaperMC/Paper/issues/1537

Resolves #1537
This commit is contained in:
Aikar 2018-10-10 23:18:02 -04:00
parent e020015aad
commit 14de21393c
No known key found for this signature in database
GPG key ID: 401ADFC9891FAAFE
3 changed files with 27 additions and 20 deletions

View file

@ -1,14 +1,14 @@
From 6c52b93ddc7893987c26ac9eab4f2ddbd86f50e6 Mon Sep 17 00:00:00 2001
From bb502b2f16c52b6ef4fe6ac457c423bf940618e3 Mon Sep 17 00:00:00 2001
From: Jedediah Smith <jedediah@silencegreys.com>
Date: Wed, 2 Mar 2016 23:13:07 -0600
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 0410f9cf3..6ae576a2e 100644
index 5dbd493f41..a049b8d68e 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -41,7 +41,12 @@ public class EntityTrackerEntry {
@@ -41,7 +41,19 @@ public class EntityTrackerEntry {
private boolean x;
private boolean y;
public boolean b;
@ -18,11 +18,18 @@ index 0410f9cf3..6ae576a2e 100644
+ // 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();
+
+ /**
+ * Requested in https://github.com/PaperMC/Paper/issues/1537 to allow intercepting packets
+ */
+ public void sendPlayerPacket(EntityPlayer player, Packet packet) {
+ player.playerConnection.sendPacket(packet);
+ }
+ // Paper end
public EntityTrackerEntry(Entity entity, int i, int j, int k, boolean flag) {
this.tracker = entity;
@@ -142,6 +147,7 @@ public class EntityTrackerEntry {
@@ -142,6 +154,7 @@ public class EntityTrackerEntry {
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;
@ -30,7 +37,7 @@ index 0410f9cf3..6ae576a2e 100644
// CraftBukkit start - Code moved from below
if (flag1) {
this.xLoc = k;
@@ -155,7 +161,6 @@ public class EntityTrackerEntry {
@@ -155,7 +168,6 @@ public class EntityTrackerEntry {
}
// CraftBukkit end
@ -38,7 +45,7 @@ index 0410f9cf3..6ae576a2e 100644
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) {
@@ -201,7 +206,26 @@ public class EntityTrackerEntry {
@@ -201,7 +213,26 @@ public class EntityTrackerEntry {
}
if (object != null) {
@ -56,9 +63,9 @@ index 0410f9cf3..6ae576a2e 100644
+ if (teleportPacket == null) {
+ teleportPacket = new PacketPlayOutEntityTeleport(this.tracker);
+ }
+ viewer.getKey().playerConnection.sendPacket(teleportPacket);
+ sendPlayerPacket(viewer.getKey(), teleportPacket);
+ } else {
+ viewer.getKey().playerConnection.sendPacket((Packet) object);
+ sendPlayerPacket(viewer.getKey(), (Packet) object);
+ }
+ }
+ }
@ -66,7 +73,7 @@ index 0410f9cf3..6ae576a2e 100644
}
this.d();
@@ -338,7 +362,7 @@ public class EntityTrackerEntry {
@@ -338,7 +369,7 @@ public class EntityTrackerEntry {
entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId()));
// CraftBukkit end
@ -76,5 +83,5 @@ index 0410f9cf3..6ae576a2e 100644
entityplayer.playerConnection.sendPacket(packet);
--
2.18.0
2.19.1

View file

@ -1,4 +1,4 @@
From f9a4f6c9d88b8c4a95936a8597507bbed44b19ca Mon Sep 17 00:00:00 2001
From c4f943b3f3ed9320caa7473400e429366e4d468f Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 29 Apr 2016 20:02:00 -0400
Subject: [PATCH] Improve Maps (in item frames) performance and bug fixes
@ -30,10 +30,10 @@ index 6c4c192446..ad9e7f7b54 100644
ItemStack itemstack1 = this.a(entityitem);
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index 5c75d494a2..6120c63a38 100644
index a049b8d68e..69d3b4f8e4 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -90,7 +90,7 @@ public class EntityTrackerEntry {
@@ -97,7 +97,7 @@ public class EntityTrackerEntry {
}
// PAIL : rename
@ -140,5 +140,5 @@ index 256a131781..5768cd512e 100644
public RenderData() {
--
2.19.0
2.19.1

View file

@ -1,4 +1,4 @@
From 72a1b85a6474a83316095da0c2cfe30cb1b365f5 Mon Sep 17 00:00:00 2001
From da63912ec50ee3ed27e4473060f6a172146e123d Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 17 Jun 2013 01:24:00 -0400
Subject: [PATCH] Entity Tracking Improvements
@ -19,10 +19,10 @@ index 1474209a1e..5e5c241669 100644
if (bukkitEntity == null) {
bukkitEntity = CraftEntity.getEntity(world.getServer(), this);
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index 6120c63a38..a9d51641c1 100644
index 69d3b4f8e4..0b00ed3d00 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -49,6 +49,7 @@ public class EntityTrackerEntry {
@@ -56,6 +56,7 @@ public class EntityTrackerEntry {
// Paper end
public EntityTrackerEntry(Entity entity, int i, int j, int k, boolean flag) {
@ -30,7 +30,7 @@ index 6120c63a38..a9d51641c1 100644
this.tracker = entity;
this.e = i;
this.f = j;
@@ -446,17 +447,59 @@ public class EntityTrackerEntry {
@@ -453,17 +454,59 @@ public class EntityTrackerEntry {
this.tracker.b(entityplayer);
entityplayer.d(this.tracker);
@ -90,7 +90,7 @@ index 6120c63a38..a9d51641c1 100644
double d0 = entityplayer.locX - (double) this.xLoc / 4096.0D;
double d1 = entityplayer.locZ - (double) this.zLoc / 4096.0D;
int i = Math.min(this.e, (entityplayer.getViewDistance() - 1) * 16); // Paper - Use player view distance API
@@ -597,6 +640,7 @@ public class EntityTrackerEntry {
@@ -604,6 +647,7 @@ public class EntityTrackerEntry {
this.trackedPlayers.remove(entityplayer);
this.tracker.c(entityplayer);
entityplayer.c(this.tracker);
@ -99,5 +99,5 @@ index 6120c63a38..a9d51641c1 100644
}
--
2.19.0
2.19.1