29 lines
1.6 KiB
Diff
29 lines
1.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <wangxyper@163.com>
|
|
Date: Sun, 4 Aug 2024 22:29:01 +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 8ea2f24695f5dad55e21f238b69442513e7a90c6..08270040b4bfc6a4a65453d0d997b78425ec7a8f 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
@@ -216,6 +216,8 @@ 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.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) {
|
|
@@ -230,6 +232,7 @@ public class ServerEntity {
|
|
this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
|
|
}
|
|
}
|
|
+ } // SparklyPaper end
|
|
}
|
|
|
|
if (packet1 != null) {
|