diff --git a/patches/removed/1.19/Reduce-allocation-of-Vec3D-by-entity-tracker.patch b/patches/removed/1.19/Reduce-allocation-of-Vec3D-by-entity-tracker.patch deleted file mode 100644 index 4147c0bd1..000000000 --- a/patches/removed/1.19/Reduce-allocation-of-Vec3D-by-entity-tracker.patch +++ /dev/null @@ -1,39 +0,0 @@ -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 - -Part of this patch was merged, see the same name - -diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 5e3f489964489e0facc93a823a1cb84b4c8abce7..1a4350b40d15edba998e3dee5f16cde4e9f50759 100644 ---- 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 { - ++this.teleportDelay; - i = Mth.floor(this.entity.getYRot() * 256.0F / 360.0F); - j = Mth.floor(this.entity.getXRot() * 256.0F / 360.0F); -- 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 { - // CraftBukkit end - - 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; - - if (!flag4 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.isOnGround()) { diff --git a/patches/server/0420-Reduce-allocation-of-Vec3D-by-entity-tracker.patch b/patches/server/0420-Reduce-allocation-of-Vec3D-by-entity-tracker.patch index 3b6e7789e..416ddd6f1 100644 --- a/patches/server/0420-Reduce-allocation-of-Vec3D-by-entity-tracker.patch +++ b/patches/server/0420-Reduce-allocation-of-Vec3D-by-entity-tracker.patch @@ -4,6 +4,19 @@ Date: Mon, 27 Apr 2020 00:04:16 -0700 Subject: [PATCH] Reduce allocation of Vec3D by entity tracker +diff --git a/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java b/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java +index 3167f5c6be39757e3cc42cbb17ab0cf13a2fe470..3768a71491ef7836b9739bdaec7a077c523dbacd 100644 +--- a/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java ++++ b/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java +@@ -5,7 +5,7 @@ import net.minecraft.world.phys.Vec3; + + public class VecDeltaCodec { + private static final double TRUNCATION_STEPS = 4096.0D; +- private Vec3 base = Vec3.ZERO; ++ public Vec3 base = Vec3.ZERO; // Paper + + private static long encode(double value) { + return Mth.lfloor(value * 4096.0D); diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java index 4aebad2b6a7b70b335b7aa1d87d7d2383861e587..fa6329b04ca185c7b12f2d782f109b94b19f9cc6 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -24,3 +37,22 @@ index 4aebad2b6a7b70b335b7aa1d87d7d2383861e587..fa6329b04ca185c7b12f2d782f109b94 double d2 = d0 * d0; boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player); +diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java +index 7881176a900daa3306c691454f688c1f79b73475..ddc5b4849939a96b76611cfa1cd34c06c7acc0f8 100644 +--- a/src/main/java/net/minecraft/server/level/ServerEntity.java ++++ b/src/main/java/net/minecraft/server/level/ServerEntity.java +@@ -147,7 +147,13 @@ public class ServerEntity { + i = Mth.floor(this.entity.getYRot() * 256.0F / 360.0F); + j = Mth.floor(this.entity.getXRot() * 256.0F / 360.0F); + Vec3 vec3d = this.entity.trackingPosition(); +- boolean flag1 = this.positionCodec.delta(vec3d).lengthSqr() >= 7.62939453125E-6D; ++ // Paper start - reduce allocation of Vec3D here ++ Vec3 base = this.positionCodec.base; ++ double vec3d_dx = vec3d.x - base.x; ++ double vec3d_dy = vec3d.y - base.y; ++ double vec3d_dz = vec3d.z - base.z; ++ 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; diff --git a/patches/server/0751-Send-full-pos-packets-for-hard-colliding-entities.patch b/patches/server/0751-Send-full-pos-packets-for-hard-colliding-entities.patch index 204e9d0eb..b63f55bd8 100644 --- a/patches/server/0751-Send-full-pos-packets-for-hard-colliding-entities.patch +++ b/patches/server/0751-Send-full-pos-packets-for-hard-colliding-entities.patch @@ -9,10 +9,10 @@ Configurable under `send-full-pos-for-hard-colliding-entities` diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 8988561facae5c41dc64929d742316b104ddbbfa..01ee5eb27571847fff6e8cbd5b32b823121ccb8b 100644 +index c84ec3b93f2783de7a2815f23a9f1de89c1ab109..cc418554b655ea4111631e4a1abf69776e150e7c 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -158,7 +158,7 @@ public class ServerEntity { +@@ -164,7 +164,7 @@ public class ServerEntity { long i1 = this.positionCodec.encodeZ(vec3d); boolean flag4 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L; diff --git a/patches/server/0793-Prevent-sending-oversized-item-data-in-equipment-and.patch b/patches/server/0793-Prevent-sending-oversized-item-data-in-equipment-and.patch index cf9b61711..98fa76c07 100644 --- a/patches/server/0793-Prevent-sending-oversized-item-data-in-equipment-and.patch +++ b/patches/server/0793-Prevent-sending-oversized-item-data-in-equipment-and.patch @@ -18,10 +18,10 @@ index 0c79613597e9ed1fbeeb36e9cb60a70bbda17bb9..79593d42ef881aa96eab7ea1e50683fa @Override diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 01ee5eb27571847fff6e8cbd5b32b823121ccb8b..69c5145136c7d5303e9a1ad93fa981faf0033055 100644 +index cc418554b655ea4111631e4a1abf69776e150e7c..319dfa82dff1fe188a52bed5aa2d39575853b793 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -303,7 +303,10 @@ public class ServerEntity { +@@ -309,7 +309,10 @@ public class ServerEntity { ItemStack itemstack = ((LivingEntity) this.entity).getItemBySlot(enumitemslot); if (!itemstack.isEmpty()) { diff --git a/patches/server/0794-Hide-unnecessary-itemmeta-from-clients.patch b/patches/server/0794-Hide-unnecessary-itemmeta-from-clients.patch index a5c9c326a..a6171c0cc 100644 --- a/patches/server/0794-Hide-unnecessary-itemmeta-from-clients.patch +++ b/patches/server/0794-Hide-unnecessary-itemmeta-from-clients.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Hide unnecessary itemmeta from clients diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 69c5145136c7d5303e9a1ad93fa981faf0033055..ed7004cb5f5aa6c330d3783cb7b4bfeaeb69aba2 100644 +index 319dfa82dff1fe188a52bed5aa2d39575853b793..919758363c7b703cb200582768e68c97ce5c807a 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -305,7 +305,7 @@ public class ServerEntity { +@@ -311,7 +311,7 @@ public class ServerEntity { if (!itemstack.isEmpty()) { // Paper start - prevent oversized data final ItemStack sanitized = LivingEntity.sanitizeItemStack(itemstack.copy(), false); diff --git a/patches/server/0854-Fix-Entity-Position-Desync.patch b/patches/server/0854-Fix-Entity-Position-Desync.patch index b5130a4c3..f4b0a0dc5 100644 --- a/patches/server/0854-Fix-Entity-Position-Desync.patch +++ b/patches/server/0854-Fix-Entity-Position-Desync.patch @@ -9,10 +9,10 @@ This excludes hanging entities, as this fix caused problematic behavior due to t position field. diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index ed7004cb5f5aa6c330d3783cb7b4bfeaeb69aba2..946cde51334568c62d9546254a8d4e5d46d95324 100644 +index 919758363c7b703cb200582768e68c97ce5c807a..3b144c820531122eb37d41be06c182b5f5dc0724 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -152,7 +152,7 @@ public class ServerEntity { +@@ -158,7 +158,7 @@ public class ServerEntity { boolean flag2 = flag1 || this.tickCount % 60 == 0; boolean flag3 = Math.abs(i - this.yRotp) >= 1 || Math.abs(j - this.xRotp) >= 1;