Files
LuminolMC/patches/server/0051-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch
2025-01-11 18:41:51 +08:00

29 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <wangxyper@163.com>
Date: Wed, 4 Dec 2024 23:51:38 +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 103e2c414780be66324bcb9cd4ea539bbdfe12ad..3ea1ae600a730b1bb3488b79d145c65419687947 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -230,6 +230,8 @@ public class ServerEntity {
if (this.entity.hasImpulse || this.trackDelta || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) {
Vec3 vec3d1 = this.entity.getDeltaMovement();
+
+ if (vec3d1 != this.lastSentMovement) { // SparklyPaper start - skip distanceToSqr call in ServerEntity#sendChanges if the delta movement hasn't changed
double d0 = vec3d1.distanceToSqr(this.lastSentMovement);
if (d0 > 1.0E-7D || d0 > 0.0D && vec3d1.lengthSqr() == 0.0D) {
@@ -244,6 +246,7 @@ public class ServerEntity {
this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
}
}
+ } // SparklyPaper end
}
if (packet1 != null) {