31 lines
1.8 KiB
Diff
31 lines
1.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <wangxyper@163.com>
|
|
Date: Sun, 12 Jan 2025 15:37:25 +0800
|
|
Subject: [PATCH] SparklyPaper: Skip "distanceToSqr" call in
|
|
"ServerEntity#sendChanges" if the delta movement hasn't changed
|
|
|
|
Co-authored by: MrPowerGamerBR <git@mrpowergamerbr.com>
|
|
As part of: SparklyPaper (https://github.com/SparklyPower/SparklyPaper/blob/a69d3690472c9967772ffd4d4bd1f41403b7ea6f/sparklypaper-server/minecraft-patches/features/0002-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch)
|
|
|
|
diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
|
|
index 2d4c68b01cc1508a1a4715a91316a7db80d4efa2..3a9293d5328ef0befa0b709169489b61a2266807 100644
|
|
--- a/net/minecraft/server/level/ServerEntity.java
|
|
+++ b/net/minecraft/server/level/ServerEntity.java
|
|
@@ -209,6 +209,8 @@ public class ServerEntity {
|
|
|
|
if (this.entity.hasImpulse || this.trackDelta || this.entity instanceof LivingEntity && ((LivingEntity)this.entity).isFallFlying()) {
|
|
Vec3 deltaMovement = this.entity.getDeltaMovement();
|
|
+
|
|
+ if (deltaMovement != this.lastSentMovement) { // SparklyPaper start - skip distanceToSqr call in ServerEntity#sendChanges if the delta movement hasn't changed
|
|
double d = deltaMovement.distanceToSqr(this.lastSentMovement);
|
|
if (d > 1.0E-7 || d > 0.0 && deltaMovement.lengthSqr() == 0.0) {
|
|
this.lastSentMovement = deltaMovement;
|
|
@@ -226,6 +228,7 @@ public class ServerEntity {
|
|
this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
|
|
}
|
|
}
|
|
+ } // SparklyPaper end
|
|
}
|
|
|
|
if (packet != null) {
|