mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
54 lines
3.5 KiB
Diff
54 lines
3.5 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] Skip distanceToSqr call in ServerEntity#sendChanges if the
|
|
delta movement hasn't changed
|
|
|
|
|
|
diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
|
|
index 7748183dd12434693b89d2dbc8325988381857c9..372e33f22d9012348d19cc1a38504d90049a6833 100644
|
|
--- a/net/minecraft/server/level/ServerEntity.java
|
|
+++ b/net/minecraft/server/level/ServerEntity.java
|
|
@@ -200,23 +200,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.broadcast
|
|
- .accept(
|
|
- 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.broadcast
|
|
+ .accept(
|
|
+ new ClientboundBundlePacket(
|
|
+ List.of(
|
|
+ new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement),
|
|
+ new ClientboundProjectilePowerPacket(abstractHurtingProjectile.getId(), abstractHurtingProjectile.accelerationPower)
|
|
+ )
|
|
)
|
|
- )
|
|
- );
|
|
- } else {
|
|
- this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
|
|
+ );
|
|
+ } else {
|
|
+ this.broadcast.accept(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) {
|