Due to optimizations in 1.20.2 (23w32a) on the network protocol, in some cases, multiple packets are bundled together and sent to the client at once to save bandwidth.
BundlePacket.java
public abstract class BundlePacket<T extends PacketListener> implements Packet<T> {
private final Iterable<Packet<T>> packets;
protected BundlePacket(Iterable<Packet<T>> packets) {
this.packets = packets;
}
public final Iterable<Packet<T>> getPackets() {
return this.packets;
}
public final void write(PacketByteBuf buf) {
}
}
BundleS2CPacket.java
public class BundleS2CPacket extends BundlePacket<ClientPlayPacketListener> {
public BundleS2CPacket(Iterable<Packet<ClientPlayPacketListener>> iterable) {
super(iterable);
}
public void apply(ClientPlayPacketListener clientPlayPacketListener) {
clientPlayPacketListener.onBundle(this);
}
}
However, PacketEvent still treats it as a single packet and does not trigger an event for each individual packet inside, which can lead to uncertainty and increase coding complexity in certain situations.
Therefore, it is recommended to adapt PacketEvent to handle this, and add a field to identify the BundlePacketS2C object to which this packet belongs. If there is none, it should be null.
LiquidBounce Branch
Nextgen
Describe your feature request.
Due to optimizations in 1.20.2 (23w32a) on the network protocol, in some cases, multiple packets are bundled together and sent to the client at once to save bandwidth.
BundlePacket.java
BundleS2CPacket.java
ClientPlayNetworkHandler.java
However, PacketEvent still treats it as a single packet and does not trigger an event for each individual packet inside, which can lead to uncertainty and increase coding complexity in certain situations.
Therefore, it is recommended to adapt PacketEvent to handle this, and add a field to identify the BundlePacketS2C object to which this packet belongs. If there is none, it should be null.
Additional context
No response