0x46 S46PacketSetCompressionLevel

Changes the compression threshold mid-game. Same as S03 but for PLAY state.

Clientbound (Server → Client) · PLAY · net/minecraft/network/play/server/S46PacketSetCompressionLevel.java

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

connectioncompression
Complete 5/8

Fields

FieldTypeDescription
thresholdVarIntNew compression threshold

Wire Encoding

FieldTypeNotes
ThresholdVarInt-1 = disable

MCP References

MCPNetHandlerPlayClient.handleSetCompressionLevel()

Handler Interface

HNDINetHandlerPlayClient

Vanilla Source

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

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

Deep Dive

Role in the protocol

Mid-connection compression threshold change. The client handler reads the VarInt threshold and, only for real network connections (isLocalChannel() false), reconfigures the Netty pipeline: it updates the threshold on the existing decompress decoder or inserts one, and symmetrically for the compress encoder. In vanilla 1.8.9 compression is negotiated once during the login state, so this play-state packet is effectively a modded-server feature.

Vanilla handling

func_175100_a guards with 'if (!netManager.isLocalChannel())' and calls netManager.setCompressionTreshold(threshold). NetworkManager.setCompressionTreshold mutates the pipeline handlers in place: NettyCompressionDecoder for incoming data and NettyCompressionEncoder for outgoing, inserting the handlers when absent and removing them when the threshold is negative. From that point every packet larger than the threshold is zlib-compressed on the wire.

Why clients touch it

No module in the 8 clients references S46 beyond the vanilla handler, the packet registry, and Rise's NetworkAPI script-bridge class list. A disabler has no use for it: compression changes do not alter packet semantics, timings, or the ability to spoof data, and the threshold is a server policy the client cannot exploit. Anything that cares about compression (packet-size spoofing) operates on payload construction, not on this control packet.

Exploit surface

The packet arrives mid-stream and the client applies it immediately, so a hostile server could toggle the threshold repeatedly; each change reconfigures the pipeline, but the cost is negligible and the result is simply a different compression ratio. A negative threshold disables compression. There is no length validation: an enormous threshold effectively disables compression for the session, which is only a bandwidth concern. The change applies to the next packet in flight, not retroactively.

Server-Side Handling

The server-side counterpart is NetworkManager.setCompressionTreshold, which the client handler invokes after receiving S46. Vanilla 1.8.9 negotiates compression once during login (the login-state S03PacketEnableCompression) and never sends S46; the packet exists for modded and plugin servers that change the threshold after the play state begins. The threshold applies to both directions from the moment the pipeline is reconfigured.

Protocol Analysis

Single VarInt threshold; any negative value disables compression. The client skips the whole operation for local channels (singleplayer and LAN), so the handler is a one-line guard around a pipeline mutation. Because the packet is processed inline in the receiving thread, the new threshold takes effect for the very next packet the encoder writes, with no handshake or acknowledgement.

Anti-Cheat Landscape

Invisible to anti-cheats. Compression level is transport policy, not gameplay data; no movement, combat or timing check reads it. The only observable effect of a changed threshold is packet sizes on the wire, which server-side proxies handle transparently.

implementation Implementation Cases

Play-state compression threshold control, handled entirely inside the Netty pipeline: the vanilla handler reconfigures the decompress and compress handlers only for non-local channels. None of the 8 clients has a module for it; it is invisible to gameplay and to anti-cheat logic.

anticheat Anti-Cheat Checks

Compression level is transport policy, not gameplay data, and the corpus reflects that: the only hit is Artemis's packet generator HardcodeMap, which maps the name PacketPlayOutSetCompression to the PacketPlayServerCompression interface for the protocol generator. That is build infrastructure, not a check. No anticheat reads the threshold; changing it only changes wire sizes, which proxies handle transparently, so there is no flag surface.

Wiki Cross-Reference

Single VarInt threshold applied mid-game to the Netty pipeline; a negative value disables compression. Takes effect on the very next packet.

Vanilla 1.8.9 negotiates compression once at login via S03; S46 exists for modded servers that change the threshold during play.

MCP 1.8.9 S46PacketSetCompressionLevel implements Packet dispatching to INetHandlerPlayClient.handleSetCompressionLevel; wire serde is readPacketData/writePacketData via readVarIntFromBuffer.

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