mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
Upstream has released updates that appear to apply and compile correctly Purpur Changes: PurpurMC/Purpur@efc76215 Add missing copper blocks to waxables and weatherables options (#1712) PurpurMC/Purpur@3ca0d663 Updated Upstream (Paper) PurpurMC/Purpur@917675d0 Updated Upstream (Paper) PurpurMC/Purpur@ffe2f809 Add option to disable Warden Sonic Boom (#1713)
60 lines
4.0 KiB
Diff
60 lines
4.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Sat, 1 Feb 2025 19:50:02 +0300
|
|
Subject: [PATCH] SparklyPaper: Skip distanceToSqr call in
|
|
ServerEntity#sendChanges if the delta movement hasn't changed
|
|
|
|
Original project: https://github.com/SparklyPower/SparklyPaper
|
|
|
|
Patch description:
|
|
|
|
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/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
|
|
index 638432a2e6506d3db6a25c068a33eeafb13cf0d6..737a6ff0bfec9b555fa425619d97b80ef95cb3e6 100644
|
|
--- a/net/minecraft/server/level/ServerEntity.java
|
|
+++ b/net/minecraft/server/level/ServerEntity.java
|
|
@@ -197,23 +197,27 @@ public class ServerEntity {
|
|
|
|
if (this.entity.hasImpulse || this.trackDelta || this.entity instanceof LivingEntity && ((LivingEntity)this.entity).isFallFlying()) {
|
|
Vec3 deltaMovement = this.entity.getDeltaMovement();
|
|
- double d = deltaMovement.distanceToSqr(this.lastSentMovement);
|
|
- if (d > 1.0E-7 || d > 0.0 && deltaMovement.lengthSqr() == 0.0) {
|
|
- this.lastSentMovement = deltaMovement;
|
|
- if (this.entity instanceof AbstractHurtingProjectile abstractHurtingProjectile) {
|
|
- this.synchronizer
|
|
- .sendToTrackingPlayers(
|
|
- new ClientboundBundlePacket(
|
|
- List.of(
|
|
- new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement),
|
|
- new ClientboundProjectilePowerPacket(abstractHurtingProjectile.getId(), abstractHurtingProjectile.accelerationPower)
|
|
+ // DivineMC start - Skip "distanceToSqr" call in "ServerEntity#sendChanges" if the delta movement hasn't changed
|
|
+ if (deltaMovement != this.lastSentMovement) {
|
|
+ double d = deltaMovement.distanceToSqr(this.lastSentMovement);
|
|
+ if (d > 1.0E-7 || d > 0.0 && deltaMovement.lengthSqr() == 0.0) {
|
|
+ this.lastSentMovement = deltaMovement;
|
|
+ if (this.entity instanceof AbstractHurtingProjectile abstractHurtingProjectile) {
|
|
+ this.synchronizer
|
|
+ .sendToTrackingPlayers(
|
|
+ new ClientboundBundlePacket(
|
|
+ List.of(
|
|
+ new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement),
|
|
+ new ClientboundProjectilePowerPacket(abstractHurtingProjectile.getId(), abstractHurtingProjectile.accelerationPower)
|
|
+ )
|
|
)
|
|
- )
|
|
- );
|
|
- } else {
|
|
- this.synchronizer.sendToTrackingPlayers(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
|
|
+ );
|
|
+ } else {
|
|
+ this.synchronizer.sendToTrackingPlayers(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
|
|
+ }
|
|
}
|
|
}
|
|
+ // DivineMC end - Skip "distanceToSqr" call in "ServerEntity#sendChanges" if the delta movement hasn't changed
|
|
}
|
|
|
|
if (packet != null) {
|