0x40 S40PacketDisconnect

Kicks the player from the server during gameplay with a JSON chat component reason message.

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

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

playerdisconnectkick
Comprehensive 8/8

Fields

FieldTypeDescription
reasonIChatComponent (JSON)Kick/disconnection reason displayed to the player

Wire Encoding

FieldTypeNotes
ReasonChat Component (JSON)JSON-serialized IChatComponent

MCP References

MCPNetHandlerPlayClient.handleDisconnect()

Handler Interface

HNDINetHandlerPlayClient

Notes

This is the PLAY-state disconnect (vs S00PacketDisconnect for LOGIN). When received, the client immediately closes the network connection and displays the disconnect screen with the reason.

Vanilla Source

S40PacketDisconnect.java50 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
import net.minecraft.util.IChatComponent;
8
9
public class S40PacketDisconnect implements Packet<INetHandlerPlayClient>
10
{
11
    private IChatComponent reason;
12
13
    public S40PacketDisconnect()
14
    {
15
    }
16
17
    public S40PacketDisconnect(IChatComponent reasonIn)
18
    {
19
        this.reason = reasonIn;
20
    }
21
22
    /**
23
     * Reads the raw packet data from the data stream.
24
     */
25
    public void readPacketData(PacketBuffer buf) throws IOException
26
    {
27
        this.reason = buf.readChatComponent();
28
    }
29
30
    /**
31
     * Writes the raw packet data to the data stream.
32
     */
33
    public void writePacketData(PacketBuffer buf) throws IOException
34
    {
35
        buf.writeChatComponent(this.reason);
36
    }
37
38
    /**
39
     * Passes this Packet on to the NetHandler for processing.
40
     */
41
    public void processPacket(INetHandlerPlayClient handler)
42
    {
43
        handler.handleDisconnect(this);
44
    }
45
46
    public IChatComponent getReason()
47
    {
48
        return this.reason;
49
    }
50
}

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

Deep Dive

Role in the protocol

The play-state kick. One IChatComponent reason, serialized as a chat component. Sent by NetHandlerPlayServer and NetworkSystem when the server closes a PLAY connection with a reason; the client's handleDisconnect closes the channel and the onDisconnect path unloads the world and shows GuiDisconnected with the reason. It is the play-state counterpart of the login-state S00PacketDisconnect, and it is the last packet on the wire before the server tears the connection down.

Vanilla handling

handleDisconnect calls netManager.closeChannel(reason), which triggers the disconnect cascade: world unload, then GuiDisconnected with the reason. The kick is one-way; there is no acknowledgement. Modules see the packet in PacketReceiveEvent before the vanilla handler runs, which is the only window for reacting to it.

Why clients touch it

Sigma 4.11 Ranking inspects the reason text: if it contains 'ban' and the player has been alive more than 15 seconds, it reports a ban stat into its kill and death ranking telemetry. Rise 5.99 StaffAlert imports S40PacketDisconnect but never branches on it; the module's real work polls the Hypixel punishment API over HTTPS. The classic AutoReconnect and AntiKick modules of the wider ecosystem (Tenacity 5.1, Gugustus) sit outside this corpus, so none of the 8 reference clients cancels the kick. Rise 6.x registers the class in the script API.

Exploit surface

The kick cannot be meaningfully cancelled: the server has already dropped the connection after sending the packet, so cancelling it only skips the disconnect screen and leaves a dead connection. The real value is reading the reason: ban detection for telemetry (Ranking) and staff-ban awareness. Reason parsing is the only client-side logic, and it is invisible to the server. Anti-cheats use S40 as the enforcement channel, not as a measurable signal.

Server-Side Handling

NetHandlerPlayServer and NetworkSystem both send S40 with a GenericFutureListener that closes the channel after the packet flushes, so the kick is fire-and-forget. The reason is built from translated chat components. The server removes the player from its world state regardless of whether the client ever processes the packet.

Protocol Analysis

Single field: a chat component serialized via writeChatComponent, which embeds the full JSON chat tree including formatting and translations. The reason string is attacker-controlled, so clients parsing it must handle arbitrary text. Registered clientbound in PLAY state; the login-state equivalent is S00PacketDisconnect at id 0x00.

Anti-Cheat Landscape

Anti-cheats use S40 as the enforcement channel: a flagged player receives one and is gone, so there is nothing to bypass inside the packet. Client-side modules can only observe it. Ranking's use is the only corpus example of reacting to the reason text, and it is telemetry, not evasion.

implementation Implementation Cases

The play-state kick. Sigma's Ranking reads the reason text for ban telemetry; Rise 5.99's StaffAlert imports the class but never uses it. None of the 8 clients cancels the kick, because the connection is already dead by the time the packet arrives.

Ranking (Sigma 4.11)

Track kills and deaths and report ban kicks to the client's ranking telemetry.

onEvent handles EventPacket; for S40PacketDisconnect it checks func_149165_c().getUnformattedText().toLowerCase().contains("ban") and ticksExisted greater than 15*20, then calls sendStat("ban", ""). The module also correlates S0B animations, S02 chat, S06 health, and S13 destroy-entity packets to attribute kills and deaths.

Source: Sigma 4.11, info/sigmaclient/module/impl/other/Ranking.java

Vanilla hook: EventPacket (via @RegisterEvent on EventAttack, EventPacket, EventUpdate).
Telemetry only. The check reads the reason after the kick is already in flight; nothing is mutated or blocked.
Variations: None in the corpus. The module is auto-enabled and hidden.
StaffAlert (Rise 5.99)

Alert when staff ban players on Hypixel by polling the punishment API. The S40 import is unused.

Imports S40PacketDisconnect at the top of the file, but the shipped handlers only process S02PacketChat (API key capture) and a periodic HTTPS poll of api.hypixel.net/punishmentstats that shows a notification when staff_total grows. The import is leftover from a planned disconnect-aware feature.

Source: Rise 5.99, dev/rise/module/impl/other/StaffAlert.java

Vanilla hook: PacketReceiveEvent, UpdateEvent.
None. The module makes outbound HTTPS calls, not packet manipulation; the S40 import never executes.
Variations: None in the corpus.
NetworkAPI (script API) (Rise 6.1.30, Rise 6.2.4)

Expose the packet class to Rise's JavaScript scripting API.

S40PacketDisconnect is listed in the clientbound Class array of NetworkAPI.java (line 107).

Source: Rise 6.1.30, com/alan/clients/script/api/NetworkAPI.java

Vanilla hook: None directly.
None. Registry only.
Variations: 6.2.4 ships the byte-identical file with the Client-release2 path prefix.
Sigma: EventPacket. Rise 5.99: PacketReceiveEvent and UpdateEvent on StaffAlert. Rise 6.x: script API table.
Sigma reads the reason text inside its event bus; Rise 5.99 imports the class without using it; Rise 6.x registers it for scripts. No client in the corpus cancels S40.

anticheat Anti-Cheat Checks

No anticheat parses the play-state disconnect packet. The only real packet references are plumbing: Artemis registers PacketPlayServerKickDisconnect (PacketRepository SERVER_PLAY+39, the GPacketPlayServerKickDisconnect wrapper, ProtocolGeneratorDirect and HardcodeMap) and Negativity declares the KICK_DISCONNECT PacketType constant. The rest of the corpus is the anticheats' own kick enforcement matched on the Kick keyword: NCP KickCommand and DenyLoginCommand, intave FaultKicks, Arc PunishmentManager and PlayerPendingKickEvent, Negativity KickCommand and PlayerCheatKickEvent, Peyang Kick, KickUtil and BanAnalyzer, CheaterDeleter TeleportVerifierCheck, Rammelkast and AntiCheatPlus PlayerListener, NESS MiscEvents, proton Kick, ThotPatrol, Daedalus, Kauri JoinListener, AutoEye AutoEyePlayerList, network-dev AlarmUtil and MenuUtil, and Bubble bubble.sk. All of them kick through Bukkit's player.kickPlayer; the server crafts S40 itself when it flushes the connection, so the packet is the enforcement channel, never a measured signal.

Wiki Cross-Reference

Play-state kick: a single JSON chat component reason. Client closes the channel, unloads the world and shows the disconnect screen.

Fire-and-forget last packet before teardown; no acknowledgement. Login-state kicks use S00 instead.

MCP 1.8.9 S40PacketDisconnect implements Packet dispatching to INetHandlerPlayClient.handleDisconnect; wire serde is readPacketData/writePacketData via readChatComponent.

1.8.9 callers: NetHandlerPlayServer.kickPlayerFromServer sends new S40PacketDisconnect (line 184) +1 more: https://github.com/Marcelektro/MavenMCP-1.8.9/blob/master/src/main/java/net/minecraft/network/NetHandlerPlayServer.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.