2020-05-17 02:05:14 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
|
|
|
Date: Mon, 27 Apr 2020 00:04:16 -0700
|
|
|
|
Subject: [PATCH] Reduce allocation of Vec3D by entity tracker
|
|
|
|
|
|
|
|
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java
|
2021-04-04 07:22:27 +00:00
|
|
|
index b64aa6c9ce906b08e43891f8c465fa4e8b2a8906..58dd349adf2bc9bac6569464ef7a7aec81729e79 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java
|
2021-04-04 07:22:27 +00:00
|
|
|
@@ -155,8 +155,12 @@ public class EntityTrackerEntry {
|
2020-05-17 02:05:14 +00:00
|
|
|
++this.o;
|
|
|
|
i = MathHelper.d(this.tracker.yaw * 256.0F / 360.0F);
|
|
|
|
j = MathHelper.d(this.tracker.pitch * 256.0F / 360.0F);
|
|
|
|
- Vec3D vec3d = this.tracker.getPositionVector().d(PacketPlayOutEntity.a(this.xLoc, this.yLoc, this.zLoc));
|
|
|
|
- boolean flag1 = vec3d.g() >= 7.62939453125E-6D;
|
|
|
|
+ // Paper start - reduce allocation of Vec3D here
|
|
|
|
+ double vec3d_dx = this.tracker.locX() - 2.44140625E-4D*(this.xLoc);
|
|
|
|
+ double vec3d_dy = this.tracker.locY() - 2.44140625E-4D*(this.yLoc);
|
|
|
|
+ double vec3d_dz = this.tracker.locZ() - 2.44140625E-4D*(this.zLoc);
|
|
|
|
+ boolean flag1 = (vec3d_dx * vec3d_dx + vec3d_dy * vec3d_dy + vec3d_dz * vec3d_dz) >= 7.62939453125E-6D;
|
|
|
|
+ // Paper end - reduce allocation of Vec3D here
|
|
|
|
Packet<?> packet1 = null;
|
|
|
|
boolean flag2 = flag1 || this.tickCounter % 60 == 0;
|
|
|
|
boolean flag3 = Math.abs(i - this.yRot) >= 1 || Math.abs(j - this.xRot) >= 1;
|
2021-04-04 07:22:27 +00:00
|
|
|
@@ -173,9 +177,11 @@ public class EntityTrackerEntry {
|
2020-05-17 02:05:14 +00:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
if (this.tickCounter > 0 || this.tracker instanceof EntityArrow) {
|
|
|
|
- long k = PacketPlayOutEntity.a(vec3d.x);
|
|
|
|
- long l = PacketPlayOutEntity.a(vec3d.y);
|
|
|
|
- long i1 = PacketPlayOutEntity.a(vec3d.z);
|
|
|
|
+ // Paper start - remove allocation of Vec3D here
|
|
|
|
+ long k = PacketPlayOutEntity.a(vec3d_dx);
|
|
|
|
+ long l = PacketPlayOutEntity.a(vec3d_dy);
|
|
|
|
+ long i1 = PacketPlayOutEntity.a(vec3d_dz);
|
|
|
|
+ // Paper end - remove allocation of Vec3D here
|
|
|
|
boolean flag4 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L;
|
|
|
|
|
2020-06-26 01:58:00 +00:00
|
|
|
if (!flag4 && this.o <= 400 && !this.q && this.r == this.tracker.isOnGround()) {
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/PlayerChunkMap.java b/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
2021-03-16 15:50:45 +00:00
|
|
|
index 5538d97e237e448a7d3eb76a57609980c3a6bddb..ede47aaaace80280756fe4463def1ea26792c9e4 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
2021-03-16 15:50:45 +00:00
|
|
|
@@ -2227,9 +2227,14 @@ Sections go from 0..16. Now whenever a section is not empty, it can potentially
|
2020-05-17 02:05:14 +00:00
|
|
|
public void updatePlayer(EntityPlayer entityplayer) {
|
|
|
|
org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot
|
|
|
|
if (entityplayer != this.tracker) {
|
|
|
|
- Vec3D vec3d = entityplayer.getPositionVector().d(this.tracker.getPositionVector()); // MC-155077, SPIGOT-5113
|
|
|
|
+ // Paper start - remove allocation of Vec3D here
|
|
|
|
+ //Vec3D vec3d = entityplayer.getPositionVector().d(this.tracker.getPositionVector()); // MC-155077, SPIGOT-5113
|
|
|
|
+ double vec3d_dx = entityplayer.locX() - this.tracker.locX();
|
|
|
|
+ double vec3d_dy = entityplayer.locY() - this.tracker.locY();
|
|
|
|
+ double vec3d_dz = entityplayer.locZ() - this.tracker.locZ();
|
|
|
|
+ // Paper end - remove allocation of Vec3D here
|
|
|
|
int i = Math.min(this.b(), (PlayerChunkMap.this.viewDistance - 1) * 16);
|
|
|
|
- boolean flag = vec3d.x >= (double) (-i) && vec3d.x <= (double) i && vec3d.z >= (double) (-i) && vec3d.z <= (double) i && this.tracker.a(entityplayer);
|
|
|
|
+ boolean flag = vec3d_dx >= (double) (-i) && vec3d_dx <= (double) i && vec3d_dz >= (double) (-i) && vec3d_dz <= (double) i && this.tracker.a(entityplayer); // Paper - remove allocation of Vec3D here
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
boolean flag1 = this.tracker.attachedToPlayer;
|