Files
LuminolMC/patches/server/0059-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch

27 lines
1.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <wangxyper@163.com>
Date: Mon, 29 Jul 2024 20:12:08 +0800
Subject: [PATCH] SparklyPaper Skip "distanceToSqr" call in
"ServerEntity#sendChanges" if the delta movement hasn't changed
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index a2279262c93408c11f5d2290b48fd794975e8cfe..17cf318b89b8ecc12331714defa23c6dcf0305b4 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -215,12 +215,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) {