0x2E S2EPacketCloseWindow

Server forces the client to close an inventory window.

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

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

inventorycontainer
Comprehensive 7/8

Fields

FieldTypeDescription
windowIdbyteWindow ID

Wire Encoding

FieldTypeNotes
Window IDunsigned byte

MCP References

MCPNetHandlerPlayClient.handleCloseWindow()

Handler Interface

HNDINetHandlerPlayClient

Vanilla Source

S2EPacketCloseWindow.java44 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 S2EPacketCloseWindow implements Packet<INetHandlerPlayClient>
9
{
10
    private int windowId;
11
12
    public S2EPacketCloseWindow()
13
    {
14
    }
15
16
    public S2EPacketCloseWindow(int windowIdIn)
17
    {
18
        this.windowId = windowIdIn;
19
    }
20
21
    /**
22
     * Passes this Packet on to the NetHandler for processing.
23
     */
24
    public void processPacket(INetHandlerPlayClient handler)
25
    {
26
        handler.handleCloseWindow(this);
27
    }
28
29
    /**
30
     * Reads the raw packet data from the data stream.
31
     */
32
    public void readPacketData(PacketBuffer buf) throws IOException
33
    {
34
        this.windowId = buf.readUnsignedByte();
35
    }
36
37
    /**
38
     * Writes the raw packet data to the data stream.
39
     */
40
    public void writePacketData(PacketBuffer buf) throws IOException
41
    {
42
        buf.writeByte(this.windowId);
43
    }
44
}

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

Deep Dive

Role in the protocol

Server-initiated window close. It carries a single unsigned byte windowId and tells the client to tear down the open container and re-sync the held item. Server-side, EntityPlayerMP.closeScreen sends it when the server decides the player's window must close, which happens on death, teleport, dimension change, and anti-cheat interventions. The client counterpart C0DPacketCloseWindow is the player-initiated echo; the S2E path is always server-driven.

Vanilla handling

NetHandlerPlayClient.handleCloseWindow calls thePlayer.func_175159_q(), which resets the carried item and closes the current screen. It does not check the windowId against the open container: any S2E closes whatever GUI is up. Server-side, EntityPlayerMP.closeScreen sends S2E with openContainer.windowId and closes the container. The asymmetry is the hook: a server can yank any GUI, and the client obeys blindly.

Why clients touch it

Two module families. NoGuiClose in Rise 5.99, 6.1.30 and 6.2.4 cancels S2E so servers cannot close the player's GUI; Rise 5.99 defaults the Chat Only setting on, meaning the cancel only applies while the chat screen is open, which preserves the ability to type while a container stays open. Rise 6.2.4 defaults it off, blocking every server close. LiquidSense Dev's KeepContainer uses S2E in the opposite direction: it reads the server's close to drop its cached container reference, and it cancels the client's own C0D close packets while the keep is armed. The other six clients (Memeware, Nekoware, Sigma, Spicy, Tenacity, November Recode 2.0) have no S2E module reference at all.

Exploit surface

The unguarded close is the surface: servers close windows to interrupt chest-stealing macros and inventory manipulation, and NoGuiClose defeats that by holding the GUI open. The cost is protocol desync: the server has closed its container while the client still shows it, so later clicks (C0E) reference a dead window. This is safe only while the player does not actually interact; the Chat Only mode exists precisely to limit the desync window to chat-while-looting use. Vanilla's failure to validate windowId on S2E also means a server can send a mismatched id to force-close anything.

Server-Side Handling

EntityPlayerMP.closeScreen sends S2E with the current openContainer.windowId, then closes the server-side container and re-syncs the held item. NetHandlerPlayClient.handleCloseWindow runs func_175159_q() unconditionally: it resets the carried item and closes whatever screen is active, ignoring the packet's windowId entirely. Because the client never validates the id, the packet is a blind close lever from the server's perspective.

Protocol Analysis

Encoding: single unsigned byte windowId. It is one of the smallest packets in the play state. The client handler performs no id comparison against openContainer.windowId, which is the load-bearing detail for NoGuiClose: cancelling the packet has no side effects beyond keeping the GUI open. The windowId matters only for server bookkeeping, since the client close path is unconditional.

Anti-Cheat Landscape

Anti-cheats flag the desync NoGuiClose creates: a window the server closed but the client keeps open will eventually produce clicks (C0E) against a dead windowId, which window-state checks flag as inventory manipulation. The Chat Only default in Rise 5.99 keeps the desync window small (chat open while looting); blocking every S2E (6.2.4 default) widens it and increases the flag surface. This is a utility module with a real anti-cheat cost, unlike the purely cosmetic filters elsewhere in this group.

implementation Implementation Cases

The server-driven window close. Rise ships NoGuiClose in all three releases to cancel S2E and hold the GUI open, with a Chat Only mode in 5.99 to limit the desync. LiquidSense Dev's KeepContainer listens to S2E to invalidate its cached container when the server closes it. The other six clients never touch the packet outside vanilla.

NoGuiClose (Rise 5.99, Rise 6.2.4, Rise 6.1.30)

Cancel server window-close packets so the player's GUI cannot be yanked away.

A PacketReceiveEvent handler cancels any S2E, gated by a Chat Only setting: when enabled, the cancel only fires while mc.currentScreen is a GuiChat. Rise 5.99 defaults Chat Only to true (onPacketReceive + event.setCancelled), Rise 6.2.4 defaults its chatonly value to false (Listener with event.setCancelled).

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

Vanilla hook: PacketReceiveEvent (onPacketReceive override in 5.99; EventLink Listener in 6.x).
Clicks against a server-closed window are the flag surface. The chat-gated variant keeps the desync brief; the unconditional variant trades safety for convenience and is the one most likely to trip window-state checks on servers that close windows for inventory-macro protection.
Variations: Rise 6.1.30 and 6.2.4 ship identical files (BooleanValue chatonly, default false). Rise 5.99 uses BooleanSetting chatOnly, default true, and the older onPacketReceive override style.
KeepContainer (LiquidSense Dev)

Keep a formerly opened inventory container accessible anywhere: re-open it with the INSERT key and suppress close packets while armed.

Stores the last non-inventory GuiContainer on ScreenEvent; pressing INSERT re-opens it via displayGuiScreen. On PacketEvent it cancels every C0DPacketCloseWindow and, for S2EPacketCloseWindow, clears the cached container when the packet's windowId matches the stored container, so the cache cannot be resurrected after the server closed it. Disabling the module sends the C0D close it had been suppressing.

Source: LiquidSense Dev, net/ccbluex/liquidbounce/features/module/modules/exploit/KeepContainer.java

Vanilla hook: LiquidBounce PacketEvent, ScreenEvent and KeyEvent.
Cancelling C0D while a window is open desyncs the client from the server's container state, the same flag surface NoGuiClose creates; the S2E listener bounds the desync by dropping the cached container as soon as the server closes it.
Variations: Rise's NoGuiClose keeps the live GUI open and never re-opens a closed container; KeepContainer instead re-opens a snapshot of a container the server believes is closed. The S2E handling is bookkeeping rather than a cancel.
Two patterns: Rise cancels S2E on the packet receive path, optionally gated by chat-screen state; LiquidSense Dev's KeepContainer reads S2E to clear its cached container and cancels C0D close packets instead.
Rise 5.99 uses the Module.onPacketReceive override and BooleanSetting; Rise 6.x uses EventLink Listener fields and BooleanValue. Both default the Chat Only gate differently (true vs false). Memeware, Nekoware, Sigma, Spicy, Tenacity and November Recode 2.0 reference S2E only in vanilla sources.

anticheat Anti-Cheat Checks

The server-close packet is consumed on the send side to reset simulated window state. Grim's CompensatedInventory closes the emulated inventory transaction-ordered after the S2E, and Artemis transaction-confirms the close to clear its inventory-open flag. Both anticheats do this so that later C0E clicks against the closed window are recognized as invalid. Intave and the classic repos only handle the client-side close (C0D) and are therefore not part of this packet's story.

CompensatedInventory close handling (Grim) (GrimAnticheat-Grim)

Reset the emulated open window when the server closes it, so clicks against a closed window are flagged.

A send-side handler matches PacketType.Play.Server.CLOSE_WINDOW and schedules closeActiveInventory as a real-time task ordered after the last transaction; the reset restores isPacketInventoryActive, sets openWindowID back to 0, swaps the menu back to the player inventory and clears the carried item. Clicks that follow with the old window id no longer match openWindowID.

Detects: Chest-stealer and inventory desync where the client keeps clicking a window the server has closed.

Source: GrimAnticheat-Grim, common/src/main/java/ac/grim/grimac/utils/latency/CompensatedInventory.java

Variations: None of Grim's other files reference the server close packet; BadPacketsP, CrashF and PacketOrderA act on the client-side C0E/C0D stream instead.
WindowClose preprocessor (Artemis) (artemisac-artemis-minecraft-anticheat)

Clear the inventory-open flag on the server close so downstream checks stop treating the player as windowed.

fastHandle matches GPacketPlayServerWindowClose and schedules a transaction-confirmed PacketAction whose pre() sets the inventory-open flag to false. The same handler resets the flag on respawn, and handle() clears it on the client's own C0D close.

Detects: Window-state desync used by inventory-manipulation modules.

Source: artemisac-artemis-minecraft-anticheat, ac.artemis.core/src/main/java/ac/artemis/core/v4/processor/miscellaneous/MiscellaneousPreProcessor.java

Variations: Kauri (funkemunky-KauriV3) PacketHandler wraps WrapperPlayServerCloseWindow and clears inventoryOpen on a keepalive action; Negativity lists CLOSE_WINDOW in both client and server PacketType sections.

Wiki Cross-Reference

The server sends this when a window is forcibly closed, for example when a chest is destroyed while open, and window ID 0 refers to the player inventory.

MCP 1.8.9 S2EPacketCloseWindow implements Packet dispatching to INetHandlerPlayClient.handleCloseWindow; wire serde is readPacketData/writePacketData via readUnsignedByte.

1.8.9 callers: EntityPlayerMP.closeScreen sends new S2EPacketCloseWindow (line 902): https://github.com/Marcelektro/MavenMCP-1.8.9/blob/master/src/main/java/net/minecraft/entity/player/EntityPlayerMP.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.