0x03 S03PacketEnableCompression

Enables zlib compression for all subsequent packets. Sets the compression threshold: packets >= this size are compressed.

Clientbound (Server → Client) · LOGIN · net/minecraft/network/login/server/S03PacketEnableCompression.java

Published 2026-06-18 · Updated 2026-10-14

logincompression
Comprehensive 7/8

Fields

FieldTypeDescription
compressionThresholdVarIntMinimum packet size in bytes before compression is applied. -1 disables compression.

Wire Encoding

FieldTypeNotes
ThresholdVarIntTypically 256 in vanilla; -1 = disabled

MCP References

MCPNetHandlerLoginClient.handleEnableCompression()

Handler Interface

HNDINetHandlerLoginClient

Notes

After this packet, all future packets start with a VarInt prefix indicating the uncompressed length. If length=0, the data is uncompressed (smaller than threshold). If length>0, the remaining data is zlib-compressed and must be inflated.

Vanilla Source

S03PacketEnableCompression.java49 lines · MCP 1.8.9Original ↗
1
package net.minecraft.network.login.server;
2
3
import java.io.IOException;
4
import net.minecraft.network.Packet;
5
import net.minecraft.network.PacketBuffer;
6
import net.minecraft.network.login.INetHandlerLoginClient;
7
8
public class S03PacketEnableCompression implements Packet<INetHandlerLoginClient>
9
{
10
    private int compressionTreshold;
11
12
    public S03PacketEnableCompression()
13
    {
14
    }
15
16
    public S03PacketEnableCompression(int compressionTresholdIn)
17
    {
18
        this.compressionTreshold = compressionTresholdIn;
19
    }
20
21
    /**
22
     * Reads the raw packet data from the data stream.
23
     */
24
    public void readPacketData(PacketBuffer buf) throws IOException
25
    {
26
        this.compressionTreshold = buf.readVarIntFromBuffer();
27
    }
28
29
    /**
30
     * Writes the raw packet data to the data stream.
31
     */
32
    public void writePacketData(PacketBuffer buf) throws IOException
33
    {
34
        buf.writeVarIntToBuffer(this.compressionTreshold);
35
    }
36
37
    /**
38
     * Passes this Packet on to the NetHandler for processing.
39
     */
40
    public void processPacket(INetHandlerLoginClient handler)
41
    {
42
        handler.handleEnableCompression(this);
43
    }
44
45
    public int getCompressionTreshold()
46
    {
47
        return this.compressionTreshold;
48
    }
49
}

Deobfuscated MCP 1.8.9 source of S03PacketEnableCompression, fetched directly from Marcelektro/MavenMCP-1.8.9 (net/minecraft/network/login/server/S03PacketEnableCompression.java) at build time and verified present.

Deep Dive

Role in the protocol

The only compression control in the 1.8 protocol, sent in the LOGIN state before the play state begins. NetHandlerLoginServer emits it with the server's configured compression threshold (vanilla 256) immediately after the login sequence accepts the player, and defers the login-to-play state flip until the write lands via a ChannelFutureListener. From that point every packet on the connection is framed with a VarInt uncompressed-length prefix: 0 means the payload is raw (below threshold), any other value means the remaining bytes are zlib data the receiver must inflate. A threshold of -1 disables compression entirely.

Vanilla handling

The client handler NetHandlerLoginClient.handleEnableCompression (func_180464_a in the MCP-named builds) does exactly one thing: networkManager.setCompressionTreshold(threshold), which swaps a compressor/decompressor codec into the Netty pipeline. The packet is processed on the Netty thread during the login phase, before the module event bus is wired to any gameplay traffic. None of the 8 clients modifies this handler: the corpus shows the vanilla file verbatim in Memeware, Nekoware, Sigma, Spicy and Tenacity, and the Rise 6.1.30/6.2.4 copies repackaged under Client-release2/Client/src/main/java with identical logic.

Why clients never touch it

The corpus contains zero non-vanilla references for this packet across all 8 clients. Intercepting it is structurally pointless: the server decides compression unilaterally and compresses anything at or past its threshold, so a client that cancels the packet desynchronizes framing and dies on the next oversized packet instead of gaining anything. The only lever would be injecting a raw ChannelHandler ahead of the codec to observe decompressed traffic earlier, which none of the 8 clients does. Modules are also simply not active during login: the connection has no world, no player and no module state.

Exploit surface

None exercised in the corpus. The packet arrives before any gameplay traffic, so anti-cheats never evaluate it and there is nothing to flag. The only failure mode is protocol-level: a client that ignores the threshold breaks framing once the first oversized packet crosses the wire, which shows up as a connection drop, not an exploit. Compression here is a bandwidth optimization, not a security boundary.

Server-Side Handling

NetHandlerLoginServer sends S03PacketEnableCompression(this.server.getNetworkCompressionTreshold()) right after the login sequence accepts the player and before the connection state flips to PLAY. The write is paired with a ChannelFutureListener so the state transition only happens once the packet is flushed. After this point the server-side pipeline compresses any outgoing packet whose encoded size reaches the threshold, and expects the client to do the same in the reverse direction. The threshold is server configuration, typically 256 in vanilla; -1 disables compression.

Protocol Analysis

Wire format is a single VarInt threshold (readVarIntFromBuffer / writeVarIntToBuffer in MCP). The length-prefix framing applies to every subsequent packet in both directions: a zero prefix marks a raw payload, a nonzero prefix gives the uncompressed length of the zlib data that follows. The switch is asymmetric in time: the S03 packet itself travels uncompressed, then both directions switch together. Ordering is preserved because the pipeline mutation is deferred until the packet write completes, so no packet can slip across the boundary mis-framed.

Anti-Cheat Landscape

Anti-cheats never see this packet: it is exchanged before the play state and before any gameplay event they track. The only party that could abuse compression framing is a MITM or proxy, and that is a transport-layer concern outside the packet itself. For cheat development the practical consequence is that packet-level inspection and injection sit above the codec in every one of the 8 clients, so compression is transparent to module code.

implementation Implementation Cases

Login-state one-shot that announces the server's compression threshold (vanilla 256) and flips both directions of the connection onto the zlib codec before play begins. No module in any of the 8 clients references it: login handlers sit outside the module event bus and the server frames compressed packets unilaterally, so there is nothing to intercept and nothing to gain.

All 8 clients ship the vanilla login handler. The corpus deltas are cosmetic: MCP-named func_180464_a in Memeware, Nekoware and Sigma versus handleEnableCompression in Rise, Spicy and Tenacity, plus the Rise 6.x repackaging under Client-release2/Client/src/main/java. No client registers a packet event for login-state traffic at all.

anticheat Anti-Cheat Checks

S03PacketEnableCompression is exchanged in the LOGIN state, before the anticheat pipeline exists, and the 50-anticheat corpus contains exactly one anticheat: Artemis, with two files that are packet-type plumbing, not checks. PacketRepository maps SERVER_LOGIN + 3 to PacketLoginOutSetCompression, and the packet interface itself is declared in the wrapper API. No anticheat hooks login-state traffic, and the server decides the compression threshold unilaterally, so there is nothing to validate, cancel or flag. The checks list is empty by corpus fact, not by omission.

Wiki Cross-Reference

The packet is entirely optional: if compression is disabled the vanilla server simply never sends it rather than sending a disable value.

When present it must be sent before Login Success, and everything after it uses the compressed packet format with a VarInt uncompressed-length prefix per packet.

MCP 1.8.9 S03PacketEnableCompression implements Packet dispatching to INetHandlerLoginClient.handleEnableCompression; wire serde is readPacketData/writePacketData via readVarIntFromBuffer.

1.8.9 callers: NetHandlerLoginServer.tryAcceptPlayer sends new S03PacketEnableCompression (line 119): https://github.com/Marcelektro/MavenMCP-1.8.9/blob/master/src/main/java/net/minecraft/server/network/NetHandlerLoginServer.java

Cross-checked against minecraft.wiki (CC BY-SA 3.0) for 1.8.9 accuracy.

Vanilla Internals

Full 1.8.9 logic-class sources that send or handle this packet, stored verbatim.