papermc/patches/removed/1.19/Reduce-allocation-of-Vec3D-by-entity-tracker.patch

40 lines
2.7 KiB
Diff
Raw Normal View History

2022-06-08 05:02:19 +00:00
1.19: the position vectors aren't the same for all entities here. Can maybe just handle them differently
I think only Paintings are different
2021-06-11 12:02:28 +00:00
2022-06-08 05:02:19 +00:00
Part of this patch was merged, see the same name
2021-06-11 12:02:28 +00:00
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
2022-03-01 05:43:03 +00:00
index 5e3f489964489e0facc93a823a1cb84b4c8abce7..1a4350b40d15edba998e3dee5f16cde4e9f50759 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -143,8 +143,12 @@ public class ServerEntity {
2021-06-11 12:02:28 +00:00
++this.teleportDelay;
2021-06-14 05:32:56 +00:00
i = Mth.floor(this.entity.getYRot() * 256.0F / 360.0F);
j = Mth.floor(this.entity.getXRot() * 256.0F / 360.0F);
2021-06-11 12:02:28 +00:00
- Vec3 vec3d = this.entity.position().subtract(ClientboundMoveEntityPacket.packetToEntity(this.xp, this.yp, this.zp));
- boolean flag1 = vec3d.lengthSqr() >= 7.62939453125E-6D;
+ // Paper start - reduce allocation of Vec3D here
+ double vec3d_dx = this.entity.getX() - 2.44140625E-4D*(this.xp);
+ double vec3d_dy = this.entity.getY() - 2.44140625E-4D*(this.yp);
+ double vec3d_dz = this.entity.getZ() - 2.44140625E-4D*(this.zp);
+ 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.tickCount % 60 == 0;
boolean flag3 = Math.abs(i - this.yRotp) >= 1 || Math.abs(j - this.xRotp) >= 1;
@@ -161,9 +165,11 @@ public class ServerEntity {
2021-06-11 12:02:28 +00:00
// CraftBukkit end
2022-06-08 05:02:19 +00:00
2021-06-11 12:02:28 +00:00
if (this.tickCount > 0 || this.entity instanceof AbstractArrow) {
- long k = ClientboundMoveEntityPacket.entityToPacket(vec3d.x);
- long l = ClientboundMoveEntityPacket.entityToPacket(vec3d.y);
- long i1 = ClientboundMoveEntityPacket.entityToPacket(vec3d.z);
+ // Paper start - remove allocation of Vec3D here
+ long k = ClientboundMoveEntityPacket.entityToPacket(vec3d_dx);
+ long l = ClientboundMoveEntityPacket.entityToPacket(vec3d_dy);
+ long i1 = ClientboundMoveEntityPacket.entityToPacket(vec3d_dz);
+ // Paper end - remove allocation of Vec3D here
boolean flag4 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L;
2022-06-08 05:02:19 +00:00
2021-06-11 12:02:28 +00:00
if (!flag4 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.isOnGround()) {