* Linear flusher * Use a queue & a single thread * Customizable flusher thread number * Use try statements
60 lines
2.9 KiB
Diff
60 lines
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
|
Date: Thu, 16 Feb 2023 01:49:54 +0200
|
|
Subject: [PATCH] Send null entity packets
|
|
|
|
This is from Purpur. Don't send null entity packets.
|
|
|
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
|
index fa829cef4033625470dfae29ddf777e6c5ab8c55..47e23a196ae5e44600a64184b69141c00235baca 100644
|
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
|
@@ -203,7 +203,10 @@ public class KaiijuConfig {
|
|
else
|
|
linearFlushThreads = Math.max(linearFlushThreads, 1);
|
|
}
|
|
+
|
|
+ public static boolean sendNullEntityPackets = true;
|
|
|
|
private static void networkSettings() {
|
|
+ sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
index 81d0b2933040a451441f660f9e46199ae3b111e3..cdbc4be679d7e096c1005eaf84b74c4877479c43 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
@@ -201,6 +201,11 @@ public class ServerEntity {
|
|
flag4 = true;
|
|
flag5 = true;
|
|
}
|
|
+ // Kaiiju start - Don't send null move entity packets
|
|
+ if (!dev.kaiijumc.kaiiju.KaiijuConfig.sendNullEntityPackets && isNullMovePacket(packet1)) {
|
|
+ packet1 = null;
|
|
+ }
|
|
+ // Kaiiju end
|
|
}
|
|
|
|
if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) {
|
|
@@ -273,6 +278,20 @@ public class ServerEntity {
|
|
});
|
|
}
|
|
|
|
+ // Kaiiju start - Don't send null move entity packets
|
|
+ private boolean isNullMovePacket(Packet<?> packet) {
|
|
+ if (packet instanceof ClientboundMoveEntityPacket move) {
|
|
+ if (packet instanceof ClientboundMoveEntityPacket.Pos)
|
|
+ return move.getXa() == 0 && move.getYa() == 0 && move.getZa() == 0;
|
|
+ if (packet instanceof ClientboundMoveEntityPacket.PosRot)
|
|
+ return move.getXa() == 0 && move.getYa() == 0 && move.getZa() == 0 && move.getyRot() == 0 && move.getxRot() == 0;
|
|
+ if (packet instanceof ClientboundMoveEntityPacket.Rot)
|
|
+ return move.getyRot() == 0 && move.getxRot() == 0;
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+ // Kaiiju end
|
|
+
|
|
public void removePairing(ServerPlayer player) {
|
|
this.entity.stopSeenByPlayer(player);
|
|
player.connection.send(new ClientboundRemoveEntitiesPacket(new int[]{this.entity.getId()}));
|