diff --git a/patches/server/0005-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch b/patches/server/0005-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch new file mode 100644 index 0000000..a95ce48 --- /dev/null +++ b/patches/server/0005-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch @@ -0,0 +1,29 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MrPowerGamerBR +Date: Wed, 15 Nov 2023 23:39:36 -0300 +Subject: [PATCH] Skip "distanceToSqr" call in "ServerEntity#sendChanges" if + the delta movement hasn't changed + +The "distanceToSqr" call is a bit expensive, so avoiding it is pretty nice, around ~15% calls are skipped with this check + +We could also check if the x,y,z coordinates are equal, but for now, let's just keep the identity check, which also helps us since Minecraft's code does reuse the original delta movement Vec3 object + +diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java +index 35674f92a67f93382103c2766df4b678ba5c862f..aedf24ba0d64de855a59869052cbc2704e7dc134 100644 +--- a/src/main/java/net/minecraft/server/level/ServerEntity.java ++++ b/src/main/java/net/minecraft/server/level/ServerEntity.java +@@ -202,12 +202,14 @@ public class ServerEntity { + + if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) { + Vec3 vec3d1 = this.entity.getDeltaMovement(); ++ if (vec3d1 != this.ap) { // SparklyPaper start - skip distanceToSqr call in ServerEntity#sendChanges if the delta movement hasn't changed + double d0 = vec3d1.distanceToSqr(this.ap); + + if (d0 > 1.0E-7D || d0 > 0.0D && vec3d1.lengthSqr() == 0.0D) { + this.ap = vec3d1; + this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.ap)); + } ++ } // SparklyPaper end + } + + if (packet1 != null) { diff --git a/patches/server/0005-Track-how-much-MSPT-each-world-used.patch b/patches/server/0006-Track-how-much-MSPT-each-world-used.patch similarity index 100% rename from patches/server/0005-Track-how-much-MSPT-each-world-used.patch rename to patches/server/0006-Track-how-much-MSPT-each-world-used.patch diff --git a/patches/server/0006-Parallel-world-ticking.patch b/patches/server/0007-Parallel-world-ticking.patch similarity index 99% rename from patches/server/0006-Parallel-world-ticking.patch rename to patches/server/0007-Parallel-world-ticking.patch index e50632b..fb69cd8 100644 --- a/patches/server/0006-Parallel-world-ticking.patch +++ b/patches/server/0007-Parallel-world-ticking.patch @@ -1083,7 +1083,7 @@ index 33abcf12b4426572b74ca4c813e4392c823494bc..07198f2f8f7cb082c9e575a5c1e56c14 entityplayer1.connection = entityplayer.connection; diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index c655c6fee393c62ba79301f76baa72f9b1154a9a..c0f0f135d1d941c1ab18319ee93db61fa7afa823 100644 +index e544081e8214802facb77defc1e9aa765834be2a..f979d22f5bf83492133a87119686a4e136923bc0 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -934,11 +934,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {