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 c3a4fcf600e72f9e95e9df673619ce37d0480cca..2b4d3db901784a82e1ed91520a5e3d1fb8ca6b3e 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
@@ -214,6 +214,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) {
|
|
@@ -297,6 +299,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 b83a1058484e3d4d46f91d659f795f59d7087b72..9debf554deb5b7aa021502ff7d600905f56fa25c 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 {
|
|
|