0x21 S21PacketChunkData

Sends a chunk section (16x16x16 blocks) with compressed block data, light values, and biome info.

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

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

worldchunkblock
Comprehensive 7/8

Fields

FieldTypeDescription
chunkXintChunk X coordinate
chunkZintChunk Z coordinate
groundUpContinuousbooleanTrue if this is a fresh chunk (sends biome + skylight)
bitmaskunsigned shortWhich 16-block sections are present (bit 0 = bottom section)
dataLengthVarIntSize of compressed data
databyte[]Zlib-compressed chunk data (block IDs + block light + sky light + biomes)

Wire Encoding

FieldTypeNotes
Chunk Xint
Chunk Zint
Ground-UpboolFull chunk vs partial update
Primary Bitmaskunsigned shortWhich sections are included
Data SizeVarIntCompressed data length
Databyte[]Compressed NBT-like block data

MCP References

MCPNetHandlerPlayClient.handleChunkData()

Handler Interface

HNDINetHandlerPlayClient

Notes

Each section in the bitmask contains: 4096 block IDs (2 bytes each), 2048 block light (4 bits per block), 2048 sky light (4 bits per block). For groundUp=true: 256 biome bytes at end. Data is zlib-compressed. XRay modules intercept this to replace block IDs or prevent chunk updates.

Vanilla Source

S21PacketChunkData.java161 lines · MCP 1.8.9Original ↗
1
package net.minecraft.network.play.server;
2
3
import com.google.common.collect.Lists;
4
import java.io.IOException;
5
import java.util.List;
6
import net.minecraft.network.Packet;
7
import net.minecraft.network.PacketBuffer;
8
import net.minecraft.network.play.INetHandlerPlayClient;
9
import net.minecraft.world.chunk.Chunk;
10
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
11
12
public class S21PacketChunkData implements Packet<INetHandlerPlayClient>
13
{
14
    private int chunkX;
15
    private int chunkZ;
16
    private S21PacketChunkData.Extracted extractedData;
17
    private boolean field_149279_g;
18
19
    public S21PacketChunkData()
20
    {
21
    }
22
23
    public S21PacketChunkData(Chunk chunkIn, boolean p_i45196_2_, int p_i45196_3_)
24
    {
25
        this.chunkX = chunkIn.xPosition;
26
        this.chunkZ = chunkIn.zPosition;
27
        this.field_149279_g = p_i45196_2_;
28
        this.extractedData = getExtractedData(chunkIn, p_i45196_2_, !chunkIn.getWorld().provider.getHasNoSky(), p_i45196_3_);
29
    }
30
31
    /**
32
     * Reads the raw packet data from the data stream.
33
     */
34
    public void readPacketData(PacketBuffer buf) throws IOException
35
    {
36
        this.chunkX = buf.readInt();
37
        this.chunkZ = buf.readInt();
38
        this.field_149279_g = buf.readBoolean();
39
        this.extractedData = new S21PacketChunkData.Extracted();
40
        this.extractedData.dataSize = buf.readShort();
41
        this.extractedData.data = buf.readByteArray();
42
    }
43
44
    /**
45
     * Writes the raw packet data to the data stream.
46
     */
47
    public void writePacketData(PacketBuffer buf) throws IOException
48
    {
49
        buf.writeInt(this.chunkX);
50
        buf.writeInt(this.chunkZ);
51
        buf.writeBoolean(this.field_149279_g);
52
        buf.writeShort((short)(this.extractedData.dataSize & 65535));
53
        buf.writeByteArray(this.extractedData.data);
54
    }
55
56
    /**
57
     * Passes this Packet on to the NetHandler for processing.
58
     */
59
    public void processPacket(INetHandlerPlayClient handler)
60
    {
61
        handler.handleChunkData(this);
62
    }
63
64
    public byte[] getExtractedDataBytes()
65
    {
66
        return this.extractedData.data;
67
    }
68
69
    protected static int func_180737_a(int p_180737_0_, boolean p_180737_1_, boolean p_180737_2_)
70
    {
71
        int i = p_180737_0_ * 2 * 16 * 16 * 16;
72
        int j = p_180737_0_ * 16 * 16 * 16 / 2;
73
        int k = p_180737_1_ ? p_180737_0_ * 16 * 16 * 16 / 2 : 0;
74
        int l = p_180737_2_ ? 256 : 0;
75
        return i + j + k + l;
76
    }
77
78
    public static S21PacketChunkData.Extracted getExtractedData(Chunk p_179756_0_, boolean p_179756_1_, boolean p_179756_2_, int p_179756_3_)
79
    {
80
        ExtendedBlockStorage[] aextendedblockstorage = p_179756_0_.getBlockStorageArray();
81
        S21PacketChunkData.Extracted s21packetchunkdata$extracted = new S21PacketChunkData.Extracted();
82
        List<ExtendedBlockStorage> list = Lists.<ExtendedBlockStorage>newArrayList();
83
84
        for (int i = 0; i < aextendedblockstorage.length; ++i)
85
        {
86
            ExtendedBlockStorage extendedblockstorage = aextendedblockstorage[i];
87
88
            if (extendedblockstorage != null && (!p_179756_1_ || !extendedblockstorage.isEmpty()) && (p_179756_3_ & 1 << i) != 0)
89
            {
90
                s21packetchunkdata$extracted.dataSize |= 1 << i;
91
                list.add(extendedblockstorage);
92
            }
93
        }
94
95
        s21packetchunkdata$extracted.data = new byte[func_180737_a(Integer.bitCount(s21packetchunkdata$extracted.dataSize), p_179756_2_, p_179756_1_)];
96
        int j = 0;
97
98
        for (ExtendedBlockStorage extendedblockstorage1 : list)
99
        {
100
            char[] achar = extendedblockstorage1.getData();
101
102
            for (char c0 : achar)
103
            {
104
                s21packetchunkdata$extracted.data[j++] = (byte)(c0 & 255);
105
                s21packetchunkdata$extracted.data[j++] = (byte)(c0 >> 8 & 255);
106
            }
107
        }
108
109
        for (ExtendedBlockStorage extendedblockstorage2 : list)
110
        {
111
            j = func_179757_a(extendedblockstorage2.getBlocklightArray().getData(), s21packetchunkdata$extracted.data, j);
112
        }
113
114
        if (p_179756_2_)
115
        {
116
            for (ExtendedBlockStorage extendedblockstorage3 : list)
117
            {
118
                j = func_179757_a(extendedblockstorage3.getSkylightArray().getData(), s21packetchunkdata$extracted.data, j);
119
            }
120
        }
121
122
        if (p_179756_1_)
123
        {
124
            func_179757_a(p_179756_0_.getBiomeArray(), s21packetchunkdata$extracted.data, j);
125
        }
126
127
        return s21packetchunkdata$extracted;
128
    }
129
130
    private static int func_179757_a(byte[] p_179757_0_, byte[] p_179757_1_, int p_179757_2_)
131
    {
132
        System.arraycopy(p_179757_0_, 0, p_179757_1_, p_179757_2_, p_179757_0_.length);
133
        return p_179757_2_ + p_179757_0_.length;
134
    }
135
136
    public int getChunkX()
137
    {
138
        return this.chunkX;
139
    }
140
141
    public int getChunkZ()
142
    {
143
        return this.chunkZ;
144
    }
145
146
    public int getExtractedSize()
147
    {
148
        return this.extractedData.dataSize;
149
    }
150
151
    public boolean func_149274_i()
152
    {
153
        return this.field_149279_g;
154
    }
155
156
    public static class Extracted
157
    {
158
        public byte[] data;
159
        public int dataSize;
160
    }
161
}

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

Deep Dive

Role in the protocol

S21PacketChunkData carries one chunk's block, light and biome data. Server send sites: PlayerManager sends a ground-up chunk on initial load (line 365 in the corpus) and section updates with a bitmask on the chunk update tick (line 447), EntityPlayerMP sends the player's spawn chunk with bitmask 65535, and S26PacketMapChunkBulk is the multi-chunk variant. Wire layout: chunkX int, chunkZ int, groundUpContinuous bool, bitmask unsigned short, dataLength VarInt, then zlib-compressed bytes holding per-section block IDs, block light, sky light and 256 biome bytes for ground-up chunks.

Vanilla handling

NetHandlerPlayClient.handleChunkData first handles unloads: a ground-up packet with bitmask 0 calls doPreChunk(false). Otherwise it invalidates the block receive region, fetches the chunk (loading it if missing), applies the extracted sections through chunk.func_177439_a, marks the range for render update, and resets relight checks for non-surface dimensions. This is the heaviest decompression and block-write path in the play state, and it runs on the client thread.

Why clients touch it

None of the 8 reference clients hook S21 in a module. The only non-vanilla corpus hit is Rise 6.1.30/6.2.4 NetworkAPI, which registers the class (clientbound index 76) so scripts can synthesize chunk packets. The XRay/Search/ChestESP entries from older docs reference Sigma 3.9, which is not in the reference set. Modules that want block data read the loaded Chunk object after vanilla applies it; rewriting chunk content would force them to decompress and re-encode the packed sections, which none of these clients does.

Exploit surface

Cancelling S21 empties the client's view of the world while the player stays in the server world, the core of chunk-void behavior; the server never notices because there is no acknowledgement. The heavier abuse is bandwidth: PlayerManager caps per-tick chunk traffic server-side, but a plugin that floods S21 can stall a client's single-threaded handler. On the client side, Rise 6.x scripts can call receivePacket with a fabricated S21 to draw fake terrain locally, which is render-only and has no server effect.

Server-Side Handling

PlayerManager sends ground-up S21 (bitmask 0, line 365) when a player enters a chunk's watch range, and section updates (groundUp=false, line 447) on the per-chunk update tick, batching changed sections into the bitmask. EntityPlayerMP sends the spawn chunk with all 16 sections (65535). Chunk data is extracted and zlib-compressed at send time; there is no inbound handler because the packet is clientbound.

Protocol Analysis

Each section in the bitmask contributes 4096 block IDs at 2 bytes each plus 2048 block-light and 2048 sky-light nibbles; ground-up chunks append 256 biome bytes. The data field is zlib-compressed as a whole, so the client must inflate it before touching any block. A ground-up packet with bitmask 0 means chunk unload, not empty data. S26PacketMapChunkBulk reuses S21PacketChunkData.Extracted for the bulk variant.

Anti-Cheat Landscape

Anti-cheats never measure S21; the server cannot tell what the client rendered. Chunk-based cheats (XRay, cave finder) are undetectable server-side in principle, which is why they are banned by staff rather than flagged. The client-side risk is stability: malformed or flooded chunk data crashes the vanilla handler, the basis of chunk-ban exploits that server plugins mitigate by validating senders.

implementation Implementation Cases

Chunk payload delivery with zero module usage in the 8 reference clients: block-aware features read the loaded world instead of hooking the packet, and the only non-vanilla reference is the Rise 6.x script registry entry.

No module in the 8 clients registers a receive handler for S21. Rise 6.x exposes the class to scripts via NetworkAPI; all other references are vanilla net/minecraft files.
All 8 clients ship the vanilla handleChunkData. Rise 6.1.30/6.2.4 additionally list the class in NetworkAPI; Memeware, Nekoware, Sigma, Spicy and Tenacity differ only in the bundled vanilla source revision.

anticheat Anti-Cheat Checks

S21 delivers a full chunk column to the client, and it is the transport that makes xray and world-downloader cheating possible. Server-side anticheats approach it from two directions: xray checks score ore-breaking behavior (BAC XRayCheck, AntiCheatPlus XRayListener, Negativity XRayProtocol), sentinel modules neutralize world downloaders at the plugin-message level (Photon WorldDownloaderSentinel), and simulation anticheats parse the chunk bytes into a compensated world so their movement and phase checks see the same blocks the client sees (Grim PacketWorldReaderEight, Hydro WorldTracker, Truthful CompensatedWorld, Kauri Chunk and World, Intave block caches). The corpus for S21 is dominated by the replication side, because every block-based check depends on it.

XRayCheck (BasicAntiCheat) (MC-Jinky-BasicAntiCheat)

Ghost-block xray heuristic: spawn fake ore blocks in front of the player and flag anyone who breaks them.

On BlockBreakEvent, when the player breaks an ore, the check walks up to 9 blocks in the player's facing direction and replaces a buried stone block with the same ore type, recording it as a ghost block with a proximity counter. On PlayerMoveEvent, ghost blocks that the player approaches too often and then breaks (5 or more close encounters) fail the check; sneaking while standing over a block also registers it. The check is marked as heavy beta in the config.

Detects: Xray users who path straight to ores through solid rock and break ghost blocks that were never visible.

Source: MC-Jinky-BasicAntiCheat, src/me/jinky/checks/world/XRayCheck.java

Variations: AntiCheatPlus XRayListener and XRayTracker score ore ratios per player instead of ghost blocks; Negativity XRayProtocol runs a similar ore-ratio heuristic; Observer ChestESP is the render-side cousin of the same idea.
XRayListener and XRayTracker (AntiCheatPlus) (m1enkrafftman-AntiCheatPlus)

Ore-ratio xray detection: players who mine far more ores per total blocks than the server average are flagged.

BlockBreakEvent feeds per-ore counters (diamond, iron, gold, lapis, redstone) and a total block counter into XRayTracker for every checked player; creative players are skipped unless checkCreativeXRay is enabled. XRayStats snapshots the counts and the scheduled XRay checker compares ratios against the server baseline at the configured alert interval.

Detects: Xray users whose ore-to-block ratio is statistically above legitimate mining.

Source: m1enkrafftman-AntiCheatPlus, src/main/java/net/dynamicdev/anticheat/xray/XRayListener.java

Variations: Negativity XRayProtocol uses the same ratio idea; BAC XRayCheck detects via ghost blocks instead; LightAntiCheat hooks unloaded-chunk movement (UnloadedChunkListener) to catch players walking through terrain that should not exist.
PacketWorldReaderEight (Grim) (GrimAnticheat-Grim)

Parse the raw S21 chunk data bytes into Grim's compensated world so simulation checks see the exact blocks the client received.

BasePacketWorldReader dispatches the outbound chunk packets: handleMapChunk reads the chunk x/z, ground-up flag, section mask and size, decodes each 16-section column with the 1.8 endian-flipped palette reader, skips biome and light arrays, and merges the result into the compensated world cache with the transaction id. The 1.9+ and 1.18 readers are separate implementations; unloads are queued via removeChunkLater.

Detects: Feeds ground, collision and phase simulation; without it, ghost-block and phase cheats would read a stale world.

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

Variations: Hydro WorldTracker and Truthful CompensatedWorld keep the same compensated cache with chunk snapshots; Kauri World and Chunk classes store WrappedBlock arrays; Intave BlockCaches and ChunkAccessPatcher build the block cache for its physics simulator; Artemis CachedWorld does the same for its emulator.
WorldDownloaderSentinel (Photon) (Photon-GitHub-AntiCheatAddition)

Detect WorldDownloader mods and disable their chunk caching, entity saving and container saving over the wdl plugin-message channel.

Registers the wdl/init and wdl/control plugin-message channels. When a client announces itself on wdl|INIT, the module answers on wdl|CONTROL with two packets that disable future functionality, general saving, chunk caching, entity and tile-entity saving and container saving per config, then runs the standard sentinel detection. Chunk data (S21 and S26) is the mod's raw material, so the module closes the hole at the channel handshake.

Detects: WorldDownloader clients that would otherwise persist every chunk the server sends.

Source: Photon-GitHub-AntiCheatAddition, src/main/java/de/photon/anticheataddition/modules/sentinel/mods/WorldDownloaderSentinel.java

Variations: No other anticheat in the corpus speaks the wdl channels; Negativity (WorldRegionBypass) and LightAntiCheat approximate the same protection with region bypass and unloaded-chunk checks.

Wiki Cross-Reference

Clientbound 0x21: chunkX and chunkZ ints, groundUp bool, bitmask short, data byte array.

Each set bit adds one 16x16x16 section: 8192 block bytes plus 2048 blocklight and 2048 skylight.

Ground-up true appends 256 biome bytes; ground-up with bitmask 0 unloads the chunk.

MCP 1.8.9 S21PacketChunkData implements Packet dispatching to INetHandlerPlayClient.handleChunkData; wire serde is readPacketData/writePacketData via readBoolean, readByteArray, readInt, readShort.

1.8.9 callers: EntityPlayerMP.? sends new S21PacketChunkData (line 340) +2 more: 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.

Module Analyses Using S21PacketChunkData

Full source walkthroughs of the modules and anti-cheats that use this packet.