55 lines
2.7 KiB
Diff
55 lines
2.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: AlphaKR93 <dev@alpha93.kr>
|
|
Date: Wed, 27 Sep 2023 22:35:19 +0900
|
|
Subject: [PATCH] Ignore useless entity packets
|
|
|
|
[REFERENCE]
|
|
- PurpurMC/Purpur
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
index 2568b4ad72a7b99484aaa048257a3b5465b63b9d..59f6f8474f77f0cb332072dfe0b4d47464c1b78a 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
@@ -206,6 +206,8 @@ public class ServerEntity {
|
|
flag4 = true;
|
|
flag5 = true;
|
|
}
|
|
+
|
|
+ if (this.level.plazmaConfig().entity.ignoreUselessPackets && isUselessPacket(packet1)) packet1 = null; // Plazma - Ignore useless entity packets
|
|
}
|
|
|
|
if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) {
|
|
@@ -278,6 +280,19 @@ public class ServerEntity {
|
|
});
|
|
}
|
|
|
|
+ // Plazma start - Ignore useless entity packets
|
|
+ private boolean isUselessPacket(@Nullable Packet<?> packet) {
|
|
+ if (!(packet instanceof ClientboundMoveEntityPacket p)) return false;
|
|
+ if (p instanceof ClientboundMoveEntityPacket.Pos)
|
|
+ return p.getXa() == 0 && p.getYa() == 0 && p.getZa() == 0;
|
|
+ if (p instanceof ClientboundMoveEntityPacket.Rot)
|
|
+ return p.getxRot() == 0 && p.getyRot() == 0;
|
|
+ if (p instanceof ClientboundMoveEntityPacket.PosRot)
|
|
+ return p.getXa() == 0 && p.getYa() == 0 && p.getZa() == 0 && p.getxRot() == 0 && p.getyRot() == 0;
|
|
+ return false;
|
|
+ }
|
|
+ // Plazma end - Ignore useless entity packets
|
|
+
|
|
public void removePairing(ServerPlayer player) {
|
|
this.entity.stopSeenByPlayer(player);
|
|
player.connection.send(new ClientboundRemoveEntitiesPacket(new int[]{this.entity.getId()}));
|
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
index 036c0b12553ae203e8c73d44dc2e3d625b812af5..909a74c19501d9440f3d2435b6514d738efcfc05 100644
|
|
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
@@ -29,6 +29,8 @@ public class WorldConfigurations extends ConfigurationPart {
|
|
public Entity entity;
|
|
public class Entity extends ConfigurationPart {
|
|
|
|
+ public boolean ignoreUselessPackets = OPTIMIZE;
|
|
+
|
|
public Phantom phantom;
|
|
public class Phantom extends ConfigurationPart {
|
|
|