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 892a334d1b1c0784ed6838d1aa066403998b9a9f..eab1b19323f588030834b9a4cecd515c817f79d1 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
@@ -198,6 +198,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) {
|
|
@@ -270,6 +275,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()}));
|