0x2B S2BPacketChangeGameState

Changes a global game state: rain toggle, gamemode change, credits, demo messages, elder guardian effect.

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

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

worldgamemodeweather
Comprehensive 8/8

Fields

FieldTypeDescription
reasonunsigned byteReason code: 0=invalidBed, 1=endRain, 2=beginRain, 3=changeGamemode, 4=credits, 5=demo, 6=arrow, 7=fadeValue, 8=fadeTime, 9=elderGuardian
valuefloatValue associated with reason (gamemode ID, rain strength, fade value)

Wire Encoding

FieldTypeNotes
ReasonUnsigned Byte0=invalidBed, 1=endRain, 2=beginRain, 3=changeGamemode, 4=credits, 5=demo, 6=arrow, 7=fade, 8=fadeTime, 9=elderGuardian
ValuefloatReason-dependent

MCP References

MCPNetHandlerPlayClient.handleChangeGameState()

Handler Interface

HNDINetHandlerPlayClient

Notes

Reason 0: bed can't be set (respawn). Reason 1/2: rain toggle. Reason 3: gamemode change (value=0-3). Reason 4: credits. Reason 5: demo. Reason 6: arrow hitting entity. Reason 7/8: fade values. Reason 9: elder guardian effect.

Vanilla Source

S2BPacketChangeGameState.java59 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 S2BPacketChangeGameState implements Packet<INetHandlerPlayClient>
9
{
10
    public static final String[] MESSAGE_NAMES = new String[] {"tile.bed.notValid"};
11
    private int state;
12
    private float field_149141_c;
13
14
    public S2BPacketChangeGameState()
15
    {
16
    }
17
18
    public S2BPacketChangeGameState(int stateIn, float p_i45194_2_)
19
    {
20
        this.state = stateIn;
21
        this.field_149141_c = p_i45194_2_;
22
    }
23
24
    /**
25
     * Reads the raw packet data from the data stream.
26
     */
27
    public void readPacketData(PacketBuffer buf) throws IOException
28
    {
29
        this.state = buf.readUnsignedByte();
30
        this.field_149141_c = buf.readFloat();
31
    }
32
33
    /**
34
     * Writes the raw packet data to the data stream.
35
     */
36
    public void writePacketData(PacketBuffer buf) throws IOException
37
    {
38
        buf.writeByte(this.state);
39
        buf.writeFloat(this.field_149141_c);
40
    }
41
42
    /**
43
     * Passes this Packet on to the NetHandler for processing.
44
     */
45
    public void processPacket(INetHandlerPlayClient handler)
46
    {
47
        handler.handleChangeGameState(this);
48
    }
49
50
    public int getGameState()
51
    {
52
        return this.state;
53
    }
54
55
    public float func_149137_d()
56
    {
57
        return this.field_149141_c;
58
    }
59
}

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

Deep Dive

Role in the protocol

A two-field state toggle: an unsigned byte reason and a float value. It is the server's mechanism for global client state that has no dedicated packet: rain start/stop and strength, gamemode changes, the end-game credits screen, the demo screen and its help messages, arrow-hit feedback, and the elder guardian mob-appearance effect. EntityPlayerMP sends reason 4 on end-game and reason 3 with the new GameType ID on gamemode change; WorldServer and ServerConfigurationManager drive reasons 1, 2, 7 and 8 for weather.

Vanilla handling

NetHandlerPlayClient.handleChangeGameState switches on the reason. Reason 1 sets raining true, 2 sets raining false, 3 calls playerController.setGameType(GameType.getByID(value)), 4 opens GuiWinGame, 5 routes the demo screen (value 0) or demo help messages (101/102/103), 6 plays the successful-hit sound, 7 sets rain strength, 8 sets thunder strength, 10 spawns the mob-appearance particle and guardian curse sound. Reasons with a MESSAGE_NAMES entry also push a translated chat line.

Why clients touch it

Two Rise 6.x handlers, both defensive. Ambience, a render module, cancels reasons 1 and 2 whenever the user has forced a custom weather mode, so server rain toggles cannot override the client's chosen sky. DemoCheck, a security feature, drops reason 5 with value 0, which is the demo-mode screen: a malicious or griefing server can lock a player into the demo overlay, and the check removes that lever. No client in the corpus uses this packet for AutoGG-style game-end detection; reason 4 is ignored everywhere.

Exploit surface

The demo screen (reason 5, value 0) is the abuse vector: it swaps the HUD and movement handling to demo mode, which hostile servers use to grief players. Rain reasons are a nuisance vector on weather-cycling servers, which is exactly why Ambience filters them. Reason 3 gamemode changes are server-authoritative and no client in the corpus fights them; overriding setGameType client-side desyncs the player controller and is a known crash/flag source, which is why it is absent.

Server-Side Handling

Server senders: WorldServer.updateWeather sends reason 7/8 (strengths) per dimension and reason 1/2 (rain stop/start) globally; ServerConfigurationManager sends reason 1 plus 7/8 on player join; EntityPlayerMP sends 4 on end-game and 3 with GameType.getID on gamemode change; EntityArrow sends 6 to the shooter on a successful hit; EntityGuardian sends 10 on the elder guardian effect; DemoWorldManager sends 5 with 0/101/102/103. The client handler applies each reason directly to client world state, with no validation of value ranges.

Protocol Analysis

Encoding: unsigned byte reason, float value. The value is only meaningful for reasons 3 (gamemode id), 5 (demo sub-state), 7 and 8 (weather strengths). Reasons 0, 4, 6, 9, 10 carry value 0.0F. MESSAGE_NAMES maps reasons 1, 3, 4, 5 to chat translations, so some reasons produce both a state change and a chat line. Reason 9 is defined but unused in 1.8.9; reason 10 is the elder guardian variant.

Anti-Cheat Landscape

No anti-cheat measures this packet. Gamemode changes are server-authoritative and instant, so client-side gamemode spoofing is a desync crash rather than a cheat. The defensive angle is server trust: DemoCheck exists because a hostile server can emit reason 5 to disable normal gameplay, and Ambience exists because weather packets fight user-selected ambience. Both are filters on server-controlled state, not evasions.

implementation Implementation Cases

The catch-all state toggle: rain, gamemode, credits, demo, arrow feedback, guardian effect. The 8 clients use it only defensively: Rise 6.x Ambience filters rain toggles under forced weather, and Rise 6.x DemoCheck kills the demo-screen lockout. No game-end (credits) detection exists in this corpus.

Ambience (weather override) (Rise 6.2.4, Rise 6.1.30)

Force a chosen weather and stop server rain toggles from overriding it.

When the Weather mode is not Unchanged, the PacketReceiveEvent handler cancels every S2B whose reason is 1 or 2 (begin/end rain). A PreMotionEvent branch re-applies the forced state every 20 ticks via WorldInfo setters, and onDisable resets rain strength and weather flags to defaults.

Source: Rise 6.2.4, Client-release2/Client/src/main/java/com/alan/clients/module/impl/render/Ambience.java

Vanilla hook: PacketReceiveEvent, PreMotionEvent, Render3DEvent.
Client-only state, invisible to the server. The 20-tick re-assertion matters because the server re-sends rain state on join and on weather ticks; without it the forced weather would flicker.
Variations: Identical file in Rise 6.1.30 under com/alan/clients/module/impl/render/.
DemoCheck (security) (Rise 6.2.4, Rise 6.1.30)

Drop the demo-mode packet so a server cannot lock the client into the demo screen.

A SecurityFeature on the packet receive chain. It drops any S2B where reason is 5 and value is 0, which is exactly the packet DemoWorldManager sends to open GuiScreenDemo. The demo help messages (values 101-103) are not blocked, only the screen-opening state.

Source: Rise 6.2.4, Client-release2/Client/src/main/java/com/alan/clients/security/impl/DemoCheck.java

Vanilla hook: Security pipeline handle(Packet).
Server-trust defense, not anti-cheat. Only relevant on servers that abuse the demo state; on legit demo servers it changes nothing user-visible except skipping the overlay.
Variations: Identical file in Rise 6.1.30. No other client in the corpus filters demo state.
Rise 6.x uses PacketReceiveEvent for module-level filtering (Ambience) and the security handle(Packet) chain for feature-level filtering (DemoCheck).
Both Rise 6.x versions ship identical Ambience and DemoCheck files. Rise 5.99 has no S2B module reference at all; Memeware, Nekoware, Sigma, Spicy and Tenacity only touch the packet in vanilla NetHandlerPlayClient code.

anticheat Anti-Cheat Checks

Server-side anticheats treat the change-game-state packet as authoritative world metadata, not as a cheat surface. Grim listens on the send path to keep its simulated gamemode and death-screen state transaction-ordered with the client, and feeds the rain reasons into the compensated world; Intave subscribes to the outbound game-state change to track the pending gamemode for its ability metadata. Artemis registers the packet in its wrapper repository. No anticheat uses it to flag the player, because the server controls both the reason and the value.

GameState send listener (Grim) (GrimAnticheat-Grim)

Keep Grim's simulated gamemode and death-screen state in sync with server-sent game-state changes.

PacketSendListener on CHANGE_GAME_STATE. For CHANGE_GAME_MODE it sends a transaction and applies the new gamemode in a real-time task ordered after that transaction, clamping invalid plugin values (below 0 or past the enum) to SURVIVAL and notifying the spectate manager when leaving spectator. For ENABLE_RESPAWN_SCREEN (1.15+) it records whether the death screen is shown.

Detects: Gamemode desync between the server and the simulated player, plugin-sent invalid gamemode ids, and stale death-screen state that would corrupt the menu logic of BadPacketsM.

Source: GrimAnticheat-Grim, common/src/main/java/ac/grim/grimac/events/packets/PacketChangeGameState.java

Variations: BadPacketsM (same repo) exempts the click-window menu check for one packet when a WIN_GAME reason arrives, since the client closes and reopens its menu on the credits screen. BasePacketWorldReader tracks the rain reasons (BEGIN_RAINING, END_RAINING, RAIN_LEVEL_CHANGE) into compensatedWorld.isRaining for the movement simulation.
Gamemode tracking (Intave AbilityTracker) (intave-intave)

Track the pending gamemode on outbound game-state changes so ability metadata (flight, speed) matches what the client actually sees.

PacketSubscription on outbound GAME_STATE_CHANGE with the GameStateChangeReader. If the reason is CHANGE_GAME_MODE, the value is mapped through GameStateChangeReader.GameState and stored as a pending gamemode on AbilityMetadata; the active gamemode only flips on the next tick feedback, which keeps ability state aligned with the client's processing order. The rest of the module consumes that metadata for the critical-flying-disallow mitigation.

Detects: Fly and movement cheats that exploit the one-tick window between a gamemode change and the client applying it, plus stale flight permissions after a mode switch.

Source: intave-intave, src/main/java/de/jpx3/intave/module/tracker/player/AbilityTracker.java

Variations: GameStateChangeReader (src/main/java/de/jpx3/intave/packet/reader/GameStateChangeReader.java) resolves the reason index to the GameState enum and exposes the raw value; PacketReaders.java registers it under PacketId.Server.GAME_STATE_CHANGE.
GameStateChange wrapper (Artemis) (artemisac-artemis-minecraft-anticheat)

Register the outbound game-state packet in Artemis' packet abstraction so checks can listen to it.

The packet API declares PacketPlayServerGameStateChange and PacketRepository maps SERVER_PLAY + 36 to it. This is framework registration only; no check in the corpus consumes the wrapper.

Detects: Nothing by itself; it exists so other Artemis checks can hook the packet.

Source: artemisac-artemis-minecraft-anticheat, ac.artemis.packet.api/src/main/java/ac/artemis/packet/wrapper/server/PacketPlayServerGameStateChange.java

Variations: Negativity (Elikill58-Negativity) lists the packet as GAME_STATE_CHANGE in its PacketType registry but has no handler on it.

Wiki Cross-Reference

Reason 0 signals that no valid respawn block is available, reason 6 is sent when a player is struck by an arrow, and rain and thunder levels range from 0 to 1 with thunder rendering requiring active rain.

MCP 1.8.9 S2BPacketChangeGameState implements Packet dispatching to INetHandlerPlayClient.handleChangeGameState; wire serde is readPacketData/writePacketData via readFloat, readUnsignedByte.

1.8.9 callers: EntityGuardian.apply sends new S2BPacketChangeGameState (line 451) +5 more: https://github.com/Marcelektro/MavenMCP-1.8.9/blob/master/src/main/java/net/minecraft/entity/monster/EntityGuardian.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.