* Use libs.versions.toml * Use libs.versions.toml * Add update upstream tasks * Some cleanup
53 lines
2.6 KiB
Diff
53 lines
2.6 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
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
index c6ef510d335b8baea58c4491853414a52a06b66b..e2dcdc9f317a4ab1a9b30e482607dc041abb7035 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
@@ -200,6 +200,8 @@ public class ServerEntity {
|
|
flag4 = true;
|
|
flag5 = true;
|
|
}
|
|
+
|
|
+ if (this.level.plazmaConfig().entity.ignoreUselessPackets && isUselessPacket(packet1)) packet1 = null; // Plazma
|
|
}
|
|
|
|
if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) {
|
|
@@ -272,6 +274,19 @@ public class ServerEntity {
|
|
});
|
|
}
|
|
|
|
+ // Plazma start
|
|
+ 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
|
|
+
|
|
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 {
|
|
|