Minecraft displays the player inventory differently, according to how the window was opened. Ranges of slot indices vary in meaning between different “windows”. The Open Inventory packet indicates which window is being opened according to:
|minecraft:chest||, large chest, or|
The slot number is calculated starting at 0, counting up through the window's unique slots, and then counting through the players inventory.
For all windows, the slot in the upper-left corner of the player's inventory is slot n where n is the number of unique slots, and slot number -999 is always used for clicking outside the window.
The number of unique slots in the window is sent in the Open Window (Play, 0x2d, clientbound) packet for all storage windows (e.g. Chest, Dropper). For non-storage windows (the items get dropped when the window is closed, e.g. Workbench, Anvil), the received number of unique slots is always 0, but it can be looked up by the client from the window type.
The default inventory window, which is never explicitly opened by the server, has 9 unique slots (10 in the 1.9 snapshots).
Rectangular regions are always indexed starting with the upper-left corner and scanning across rows. If a window has a crafting region, the output slot is always slot 0 followed immediately by the input region.
Each window type is described in the following sections. All slot index ranges are inclusive and reflect the indices observed in the Minecraft protocol.
For the window properties (additional data in each window, e.g. smelting progress or enchantments), refer to the table in the Window Property packet.
This is the inventory window that the player can always open, typically by pressing E since. Before, you had to press I.
|1–4||2×2 crafting input (1 + x + 2 * y)|
|5–8||armor (head, chest, legs, feet)|
Note that this is different from inventory items stored in a player.dat file. This may help: https://gist.github.com/459a1691c3dd751db160
This is the window that is opened when the player right-clicks on a workbench.
|1–9||3×3 crafting input (1 + x + 3 * y)|
This is the window that is opened when the player right-clicks on a single chest block.
This is the window that is opened when the player right-clicks on a double chest block (two adjacent chest blocks).
|0–8||3×3 dispenser contents (x + 3 * y)|
|0||item to enchant|
|1||lapis lazuli slot|