0x30 S30PacketWindowItems
Sends the full contents of an inventory window, all slots at once. Used for initial container opening and rejected transaction recovery.
Published 2026-06-18 · Updated 2026-10-14
Fields
| Field | Type | Description |
|---|---|---|
| windowId | unsigned byte | Window ID (0 = player inventory) |
| items | ItemStack[] | Array of all ItemStacks in the window, slot by slot |
Wire Encoding
| Field | Type | Notes |
|---|---|---|
| Window ID | Unsigned Byte | |
| Count | short | Number of slots |
| Slot Data | Array of Slot | All ItemStacks |
MCP References
NetHandlerPlayClient.handleWindowItems()Handler Interface
INetHandlerPlayClientNotes
Vanilla Source
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
Deobfuscated MCP 1.8.9 source of S30PacketWindowItems, fetched directly from Marcelektro/MavenMCP-1.8.9 (net/minecraft/network/play/server/S30PacketWindowItems.java) at build time and verified present.
Deep Dive
Role in the protocol
S30PacketWindowItems is the full-window sync packet: an unsigned byte window id, a short slot count, then every slot encoding in order. The server sends it when a container opens (right after S2D PacketOpenWindow), when the player joins or respawns, and as the recovery path when a click transaction is rejected (S32 accepted=false). It is the server's authoritative statement of window contents, and the client applies it wholesale, replacing the container's slot list.
Vanilla handling
NetHandlerPlayClient.handleWindowItems maps windowId 0 and the player inventory window to inventoryContainer and everything else to the open container, then overwrites every slot via putStacksInSlots. EntityPlayerMP.updateCraftingInventory (line 773) builds the list from inventorySlots and sends S30 on every full sync. Because the client trusts the dump completely, S30 is both the sync primitive and the revert mechanism: any client-side inventory manipulation is undone the moment the server decides to re-send.
Why clients touch it
Only Rise uses S30 as a module surface in the corpus. Rise 5.99 Stealer treats it as the go signal: gotItems flips true when the chest contents land, and the steal loop only starts clicking after that flag, with a randomized per-click delay and auto-close. Rise 5.99 Aura resets its blocking flag on S30, since a full window sync invalidates the client's assumption that the sword is still blocking. Rise 6.x AdaptiveRefreshRateComponent counts S30 among the significant packets that dirty the HUD cache.
Exploit surface
S30 is the correction mechanism that makes S2F cancellation a short-horizon trick: one rejected transaction and the server pushes a full dump that reverts any ghost slot. For stealers the ordering constraint is the exploit surface: clicking before S30, or after a rejected click, races the resync and produces the visible pattern (clicking a slot whose content the server already changed) that chest-stealer heuristics flag. The packet is also the largest inventory packet on the wire, so a server that rejects transactions in a loop can force repeated full dumps, a bandwidth tax with no client-side mitigation in the corpus.
Server-Side Handling
EntityPlayerMP.updateCraftingInventory (line 773) serializes the container's inventorySlots into a List and sends S30(windowId, list) on open, respawn, and after rejected clicks. NetHandlerPlayServer.processClickWindow validates the action number; on mismatch it calls updateCraftingInventory so the client receives a corrected dump. The client handler resolves the window by id (0 and the player window map to inventoryContainer, otherwise the open container) and overwrites all slots.
Protocol Analysis
Wire: unsigned byte windowId, short count, then count Slot encodings (short id, byte count, short damage, optional NBT). Slots are ordered container-first, then player inventory 9-35, then hotbar 0-8. The cursor is not included; it is synced separately by S2F(-1,-1). A chest open produces S2D then S30 back to back, which is why inventory modules gate on S30 instead of the GUI opening event: the screen renders before the server contents arrive.
Anti-Cheat Landscape
No anti-cheat measures S30 itself; it is authoritative recovery data. The heuristics that matter sit on the clicks around it: a stealer that fires before S30, or after a rejected transaction, clicks against stale content and produces the tell-tale sequence (C0E immediately followed by the server's S30 correction). Ghost-item exploits depend on S30 never arriving for the manipulated window, so cancel-happy modules trade durability: the longer the manipulation, the more likely a full dump reverts it.
implementation Implementation Cases
The full-window sync and the revert path for rejected clicks. Rise 5.99's Stealer uses it as the trigger to start clicking chests, Aura resets its block state on it, and Rise 6.x treats it as a HUD-significant packet. Every other client in the corpus reaches it only through the vanilla handler.
Chest stealer: use S30 as the sync gate, then click every whitelisted item with randomized delays and auto-close.
onPacketReceive: if the packet is S30, set gotItems = true. onRender2DEvent: while GuiChest is open, wait a randomized decidedTimer (between min and max delay settings), then scan chest.inventorySlots and windowClick(chest.windowId, i, 0, 1, player) on the first whitelisted item, resetting the timer; auto-close via closeScreen once gotItems or ticksInChest > 10. gotItems resets whenever the player leaves the chest.
// ===== FILE: Rise 5.99, dev/rise/module/impl/player/Stealer.java =====
/*
Copyright Alan Wood 2021
None of this code to be reused without my written permission
Intellectual Rights owned by Alan Wood
*/
package dev.rise.module.impl.player;
import dev.rise.event.impl.motion.PreMotionEvent;
import dev.rise.event.impl.other.WorldChangedEvent;
import dev.rise.event.impl.packet.PacketReceiveEvent;
import dev.rise.event.impl.render.Render2DEvent;
import dev.rise.font.CustomFont;
import dev.rise.font.fontrenderer.TTFFontRenderer;
import dev.rise.module.Module;
import dev.rise.module.api.ModuleInfo;
import dev.rise.module.enums.Category;
import dev.rise.setting.impl.BooleanSetting;
import dev.rise.setting.impl.NumberSetting;
import dev.rise.util.math.TimeUtil;
import dev.rise.util.render.theme.ThemeType;
import dev.rise.util.render.theme.ThemeUtil;
import net.minecraft.block.BlockFalling;
import net.minecraft.block.BlockSlime;
import net.minecraft.block.BlockTNT;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.init.Items;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.item.*;
import net.minecraft.network.play.server.S30PacketWindowItems;
import org.apache.commons.lang3.RandomUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;
import java.util.ArrayList;
@ModuleInfo(name = "Stealer", description = "Steals items from chests", category = Category.PLAYER)
public final class Stealer extends Module {
private final TimeUtil timer = new TimeUtil();
private final TimeUtil startTimer = new TimeUtil();
private final NumberSetting minDelay = new NumberSetting("Min Delay", this, 5, 0, 1000, 25);
private final NumberSetting maxDelay = new NumberSetting("Max Delay", this, 5, 0, 1000, 25);
private final BooleanSetting stealTrashItems = new BooleanSetting("Steal trash items", this, false);
private final BooleanSetting autoClose = new BooleanSetting("Auto Close", this, true);
private final BooleanSetting hideGui = new BooleanSetting("Hide Gui", this, true);
private final BooleanSetting mouseInput = new BooleanSetting("Move head in chest", this, true);
private final BooleanSetting chestName = new BooleanSetting("Check chest name", this, false);
private final BooleanSetting disableOnWorldChange = new BooleanSetting("Disable on World Change", this, false);
private int decidedTimer = 0;
public static boolean hideChestGui, allowMouseInput, closeAfterContainer;
private boolean gotItems;
private final static TTFFontRenderer comfortaa = CustomFont.FONT_MANAGER.getFont("Comfortaa 18");
private int ticksInChest;
private boolean lastInChest;
@Override
protected void onDisable() {
closeAfterContainer = false;
allowMouseInput = false;
hideChestGui = false;
gotItems = false;
}
@Override
public void onPacketReceive(final PacketReceiveEvent event) {
if (mc.thePlayer.ticksExisted <= 60) return;
if (event.getPacket() instanceof S30PacketWindowItems) {
gotItems = true;
}
}
@Override
public void onPreMotion(final PreMotionEvent event) {
if (mc.thePlayer.ticksExisted <= 60) return;
if (mc.currentScreen instanceof GuiChest && Display.isVisible() && mouseInput.isEnabled() && hideGui.isEnabled() && (!chestName.isEnabled() || (((GuiChest) mc.currentScreen).lowerChestInventory.getDisplayName().getUnformattedText().contains("chest")))) {
mc.mouseHelper.centerMouse();
mc.mouseHelper.mouseGrab(false);
mc.mouseHelper.mouseGrab(true);
}
if (mc.currentScreen instanceof GuiChest) {
ticksInChest++;
if (ticksInChest * 50 > 255) {
ticksInChest = 10;
}
} else {
ticksInChest--;
gotItems = false;
if (ticksInChest < 0) {
ticksInChest = 0;
}
}
}
@Override
public void onRender2DEvent(final Render2DEvent event) {
if (mc.thePlayer.ticksExisted <= 60) return;
if (!lastInChest) startTimer.reset();
lastInChest = mc.currentScreen instanceof GuiChest;
if (mc.currentScreen instanceof GuiChest) {
if (hideGui.isEnabled()) {
hideChestGui = true;
}
if (mouseInput.isEnabled()) {
allowMouseInput = true;
}
if (chestName.isEnabled()) {
final String name = ((GuiChest) mc.currentScreen).lowerChestInventory.getDisplayName().getUnformattedText();
if (!name.toLowerCase().contains("chest")) return;
}
if (hideGui.isEnabled()) {
final ScaledResolution SR = new ScaledResolution(mc);
final String t = "Stealing chest... Press " + Keyboard.getKeyName(mc.gameSettings.keyBindInventory.getKeyCode()) + " to close the chest";
int o;
o = ticksInChest * 50;
if (o > 255)
o = 255;
comfortaa.drawStringWithShadow(t, SR.getScaledWidth() / 2f - comfortaa.getWidth(t) / 2f, SR.getScaledHeight() - 80, ThemeUtil.getThemeColorInt(ThemeType.GENERAL));
}
if (decidedTimer == 0) {
final int delayFirst = (int) Math.floor(Math.min(minDelay.getValue(), maxDelay.getValue()));
final int delaySecond = (int) Math.ceil(Math.max(minDelay.getValue(), maxDelay.getValue()));
decidedTimer = RandomUtils.nextInt(delayFirst, delaySecond);
}
if (timer.hasReached(decidedTimer)) {
final ContainerChest chest = (ContainerChest) mc.thePlayer.openContainer;
for (int i = 0; i < chest.inventorySlots.size(); i++) {
final ItemStack stack = chest.getLowerChestInventory().getStackInSlot(i);
if (stack != null && (itemWhitelisted(stack) && !stealTrashItems.isEnabled())) {
mc.playerController.windowClick(chest.windowId, i, 0, 1, mc.thePlayer);
timer.reset();
final int delayFirst = (int) Math.floor(Math.min(minDelay.getValue(), maxDelay.getValue()));
final int delaySecond = (int) Math.ceil(Math.max(minDelay.getValue(), maxDelay.getValue()));
decidedTimer = RandomUtils.nextInt(delayFirst, delaySecond);
gotItems = true;
return;
}
}
if (autoClose.isEnabled() && (gotItems || ticksInChest > 10)) {
mc.thePlayer.closeScreen();
}
}
} else {
hideChestGui = false;
allowMouseInput = false;
}
}
@Override
public void onWorldChanged(final WorldChangedEvent event) {
if (disableOnWorldChange.isEnabled()) {
this.toggleModule();
this.registerNotification("Disabled " + this.getModuleInfo().name() + " due to world change.");
}
}
private boolean itemWhitelisted(final ItemStack itemStack) {
final ArrayList<Item> whitelistedItems = new ArrayList<Item>() {{
add(Items.ender_pearl);
add(Items.iron_ingot);
add(Items.gold_ingot);
add(Items.redstone);
add(Items.diamond);
add(Items.emerald);
add(Items.quartz);
add(Items.bow);
add(Items.arrow);
add(Items.fishing_rod);
}};
final Item item = itemStack.getItem();
final String itemName = itemStack.getDisplayName();
if (itemName.contains("Right Click") || itemName.contains("Click to Use") || itemName.contains("Players Finder"))
return true;
final ArrayList<Integer> whitelistedPotions = new ArrayList<Integer>() {{
add(6);
add(1);
add(5);
add(8);
add(14);
add(12);
add(10);
add(16);
}};
if (item instanceof ItemPotion) {
final int potionID = getPotionId(itemStack);
return whitelistedPotions.contains(potionID);
}
return (item instanceof ItemBlock
&& !(((ItemBlock) item).getBlock() instanceof BlockTNT)
&& !(((ItemBlock) item).getBlock() instanceof BlockSlime)
&& !(((ItemBlock) item).getBlock() instanceof BlockFalling))
|| item instanceof ItemAnvilBlock
|| item instanceof ItemSword
|| item instanceof ItemArmor
|| item instanceof ItemTool
|| item instanceof ItemFood
|| item instanceof ItemSkull
|| itemName.contains("\247")
|| whitelistedItems.contains(item)
&& !item.equals(Items.spider_eye);
}
private int getPotionId(final ItemStack potion) {
final Item item = potion.getItem();
try {
if (item instanceof ItemPotion) {
final ItemPotion p = (ItemPotion) item;
return p.getEffects(potion.getMetadata()).get(0).getPotionID();
}
} catch (final NullPointerException ignored) {
}
return 0;
}
}
// NOTE (AI): gotItems is the gate: the steal loop starts only after S30 lands, so clicks never race the initial dump. The randomized delay between clicks and the whitelist in itemWhitelisted define the steal pattern; auto-close fires once the chest is empty or 10+ ticks elapsed inside it.
Reset the blocking state when a full window sync arrives.
onPacketReceive: if the packet is S30PacketWindowItems, blocking = false. The Hypixel block mode keeps a blocking flag while the sword is held up; a full window sync means the server corrected the inventory, so the client must drop its assumption that the block is still active.
HUD performance component: S30 is one of the significant packets that force a GuiIngameCache redraw.
PacketReceiveEvent: on S30, reset the StopWatch and mark the cache dirty so the next frame re-renders. Same component as the S2F entry; both packets are treated as inventory-significant events.
// ===== FILE: Rise 6.2.4, Client-release2/Client/src/main/java/com/alan/clients/component/impl/hud/AdaptiveRefreshRateComponent.java =====
package com.alan.clients.component.impl.hud;
import com.alan.clients.component.Component;
import com.alan.clients.event.Listener;
import com.alan.clients.event.annotations.EventLink;
import com.alan.clients.event.impl.motion.PreMotionEvent;
import com.alan.clients.event.impl.packet.PacketReceiveEvent;
import com.alan.clients.event.impl.render.Render2DEvent;
import com.alan.clients.ui.ingame.GuiIngameCache;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S02PacketChat;
import net.minecraft.network.play.server.S0DPacketCollectItem;
import net.minecraft.network.play.server.S2FPacketSetSlot;
import net.minecraft.network.play.server.S30PacketWindowItems;
import rip.vantage.commons.util.time.StopWatch;
public class AdaptiveRefreshRateComponent extends Component {
private boolean playerList, debugInfo;
private boolean setDirty;
private int disabledFor;
private float health;
public final StopWatch stopWatch = new StopWatch();
@EventLink
public final Listener<PreMotionEvent> onPreMotionEvent = event -> {
if (mc.thePlayer.ticksExisted % 100 == 0 || setDirty ||
mc.gameSettings.keyBindPlayerList.isKeyDown() != playerList || mc.gameSettings.showDebugInfo != debugInfo ||
mc.thePlayer.ticksExisted <= 10 || disabledFor > 0) {
GuiIngameCache.dirty = true;
playerList = mc.gameSettings.keyBindPlayerList.isKeyDown();
debugInfo = mc.gameSettings.showDebugInfo;
setDirty = false;
}
if (health != mc.thePlayer.getHealth()) {
disabledFor = 3;
health = mc.thePlayer.getHealth();
}
disabledFor--;
};
@EventLink
public final Listener<Render2DEvent> onRender2D = event -> {
if (mc.currentScreen != null) {
setDirty = true;
GuiIngameCache.dirty = true;
}
};
@EventLink
public final Listener<PacketReceiveEvent> onPacketReceiveEvent = event -> {
Packet packet = event.getPacket();
if (packet instanceof S02PacketChat || packet instanceof S30PacketWindowItems || packet instanceof S2FPacketSetSlot) {
stopWatch.reset();
setDirty = true;
}
if (packet instanceof S0DPacketCollectItem) {
disabledFor = 5;
}
};
}
// NOTE (AI): S2F and S30 are grouped with S02PacketChat as significant packets that force a HUD cache redraw; S0D collect-item disables adaptive refresh for 5 ticks. The component is byte-identical in 6.1.30 under com/alan/clients.
anticheat Anti-Cheat Checks
The window-items packet dumps the full contents of an inventory window, and for simulation anticheats it is the authoritative recovery data that resyncs the compensated inventory after rejected transactions or open-window changes. Grim consumes it in two places: the inventory mirror applies every server slot to its storage, and the entity replication listener uses window-id-0 dumps to detect held-item and offhand changes. Intave's nayoro stack models the same send as a WindowItemsEvent. No anticheat treats S30 as a detection surface on its own.
Keep the compensated copy of the player inventory aligned with the server after every full window-items send.
CompensatedInventory is a Check that listens on both directions. On WINDOW_ITEMS it wraps the packet, marks each server slot as corrected in the inventory storage, and when the window id is 0 (the player inventory) forces the packet-inventory mode back on and syncs the slot list. It tracks the open window id and the packet-sending inventory size, and falls back to the platform inventory for held item, offhand and armor reads when the packet stream is unsupported (modded menus).
// ===== FILE: GrimAnticheat-Grim, common/src/main/java/ac/grim/grimac/utils/latency/CompensatedInventory.java =====
package ac.grim.grimac.utils.latency;
import ac.grim.grimac.checks.Check;
import ac.grim.grimac.checks.type.PacketReceiveListener;
import ac.grim.grimac.checks.type.PacketSendListener;
import ac.grim.grimac.player.GrimPlayer;
import ac.grim.grimac.utils.anticheat.update.BlockPlace;
import ac.grim.grimac.utils.inventory.EquipmentType;
import ac.grim.grimac.utils.inventory.Inventory;
import ac.grim.grimac.utils.inventory.inventory.AbstractContainerMenu;
import ac.grim.grimac.utils.inventory.inventory.MenuType;
import ac.grim.grimac.utils.inventory.inventory.NotImplementedMenu;
import ac.grim.grimac.utils.lists.CorrectingPlayerInventoryStorage;
import com.github.retrooper.packetevents.PacketEvents;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.event.PacketSendEvent;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.item.ItemStack;
import com.github.retrooper.packetevents.protocol.item.type.ItemType;
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
import com.github.retrooper.packetevents.protocol.player.GameMode;
import com.github.retrooper.packetevents.protocol.player.InteractionHand;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientCreativeInventoryAction;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientHeldItemChange;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientUseItem;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerOpenHorseWindow;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerOpenWindow;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSetPlayerInventory;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSetSlot;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerWindowItems;
import lombok.Getter;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
// Updated to support modern 1.17 protocol
public class CompensatedInventory extends Check implements PacketReceiveListener, PacketSendListener {
private static final int PLAYER_INVENTORY_CASE = -1;
private static final int UNSUPPORTED_INVENTORY_CASE = -2;
// "Temporarily" public for debugging
public final Inventory inventory;
// "Temporarily" public for debugging
public AbstractContainerMenu menu;
// Not all inventories are supported due to complexity and version differences
public boolean isPacketInventoryActive = true;
public boolean needResend = false;
public int stateID = 0; // Don't mess up the last sent state ID by changing it
private int openWindowID = 0;
// Special values:
// Player inventory is -1
// Unsupported inventory is -2
private int packetSendingInventorySize = PLAYER_INVENTORY_CASE;
// The item held at the start of the current client tick (processed at the end of the previous tick)
// also updated before slot changes to account for the delay when using hotbar keybinds
// Currently only used by 1.21.11+ players to handle attribute swapping items with the ATTACK_RANGE Component
@Getter
private ItemStack startOfTickStack = ItemStack.EMPTY;
public CompensatedInventory(GrimPlayer playerData) {
super(playerData);
CorrectingPlayerInventoryStorage storage = new CorrectingPlayerInventoryStorage(player, 46);
inventory = new Inventory(playerData, storage);
menu = inventory;
}
// Meant for 1.17+ clients who send changed slots, making the server not send the entire inventory
private void markPlayerSlotAsChanged(int clicked) {
// Player inventory
if (openWindowID == 0) {
inventory.getInventoryStorage().handleClientClaimedSlotSet(clicked);
return;
}
// We don't know size of the inventory, so we can't do anything
// We will resync later.
if (menu instanceof NotImplementedMenu) return;
// 9-45 are the player inventory slots that are used
// There are 36 player slots in each menu that we care about and track.
int nonPlayerInvSize = menu.getSlots().size() - 36 + 9;
int playerInvSlotclicked = clicked - nonPlayerInvSize;
// Bypass player inventory
inventory.getInventoryStorage().handleClientClaimedSlotSet(playerInvSlotclicked);
}
public ItemStack getItemInHand(InteractionHand hand) {
return hand == InteractionHand.MAIN_HAND ? getHeldItem() : getOffHand();
}
/**
* Marks that the server has updated a slot by the specified ID in the specified inventory ID.
* @param clicked the updated slot
* @param windowID the inventory ID
*/
private void markServerForChangingSlot(int clicked, int windowID) {
// Unsupported inventory
if (packetSendingInventorySize == UNSUPPORTED_INVENTORY_CASE) return;
// Player inventory
if (packetSendingInventorySize == PLAYER_INVENTORY_CASE || windowID == 0) {
// Result slot isn't included in storage, we must ignore it
inventory.getInventoryStorage().handleServerCorrectSlot(clicked);
return;
}
// See note in above method.
int nonPlayerInvSize = menu.getSlots().size() - 36 + 9;
int playerInvSlotclicked = clicked - nonPlayerInvSize;
inventory.getInventoryStorage().handleServerCorrectSlot(playerInvSlotclicked);
}
public ItemStack getHeldItem() {
ItemStack item = isPacketInventoryActive || player.platformPlayer == null ? inventory.getHeldItem() :
player.platformPlayer.getInventory().getItemInHand();
return item == null ? ItemStack.EMPTY : item;
}
public ItemStack getOffHand() {
if (PacketEvents.getAPI().getServerManager().getVersion().isOlderThan(ServerVersion.V_1_9))
return ItemStack.EMPTY;
ItemStack item = isPacketInventoryActive || player.platformPlayer == null ? inventory.getOffhand() :
player.platformPlayer.getInventory().getItemInOffHand();
return item == null ? ItemStack.EMPTY : item;
}
public ItemStack getHelmet() {
ItemStack item = isPacketInventoryActive || player.platformPlayer == null ? inventory.getHelmet() :
player.platformPlayer.getInventory().getHelmet();
return item == null ? ItemStack.EMPTY : item;
}
public ItemStack getChestplate() {
ItemStack item = isPacketInventoryActive || player.platformPlayer == null ? inventory.getChestplate() :
player.platformPlayer.getInventory().getChestplate();
return item == null ? ItemStack.EMPTY : item;
}
public ItemStack getLeggings() {
ItemStack item = isPacketInventoryActive || player.platformPlayer == null ? inventory.getLeggings() :
player.platformPlayer.getInventory().getLeggings();
return item == null ? ItemStack.EMPTY : item;
}
public ItemStack getBoots() {
ItemStack item = isPacketInventoryActive || player.platformPlayer == null ? inventory.getBoots() :
player.platformPlayer.getInventory().getBoots();
return item == null ? ItemStack.EMPTY : item;
}
private ItemStack getByEquipmentType(EquipmentType type) {
return switch (type) {
case HEAD -> getHelmet();
case CHEST -> getChestplate();
case LEGS -> getLeggings();
case FEET -> getBoots();
case OFFHAND -> getOffHand();
case MAINHAND -> getHeldItem();
};
}
public boolean hasItemType(ItemType type) {
if (isPacketInventoryActive || player.platformPlayer == null)
return inventory.hasItemType(type);
// Fall back to platform inventories
for (ItemStack itemStack : player.platformPlayer.getInventory().getContents()) {
if (itemStack != null && itemStack.getType() == type) return true;
}
return false;
}
@Override
public void onPacketReceive(final PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.USE_ITEM) {
WrapperPlayClientUseItem item = new WrapperPlayClientUseItem(event);
ItemStack use = item.getHand() == InteractionHand.MAIN_HAND ? getHeldItem() : getOffHand();
EquipmentType equipmentType = EquipmentType.getEquipmentSlotForItem(use);
if (equipmentType != null) {
int slot;
switch (equipmentType) {
case HEAD -> slot = Inventory.SLOT_HELMET;
case CHEST -> slot = Inventory.SLOT_CHESTPLATE;
case LEGS -> slot = Inventory.SLOT_LEGGINGS;
case FEET -> slot = Inventory.SLOT_BOOTS;
default -> {
return; // Not armor, therefore we shouldn't run this code
}
}
ItemStack currentEquippedItem = getByEquipmentType(equipmentType);
// Only 1.19.4+ clients support swapping with non-empty items
if (player.getClientVersion().isOlderThan(ClientVersion.V_1_19_4) && !currentEquippedItem.isEmpty())
return;
// 1.19.4+ clients support swapping with non-empty items
int swapItemSlot = item.getHand() == InteractionHand.MAIN_HAND ? inventory.getSelected() + Inventory.HOTBAR_OFFSET : Inventory.SLOT_OFFHAND;
// Mojang implemented this stupidly, I rewrote their item swap code to make it somewhat cleaner.
// Slot in hotbar
inventory.getInventoryStorage().handleClientClaimedSlotSet(swapItemSlot);
inventory.getInventoryStorage().setItem(swapItemSlot, currentEquippedItem);
// Equipment slot
inventory.getInventoryStorage().handleClientClaimedSlotSet(slot);
inventory.getInventoryStorage().setItem(slot, use);
}
} else if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) {
WrapperPlayClientPlayerDigging dig = new WrapperPlayClientPlayerDigging(event);
// 1.8 clients don't predict dropping items
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return;
if (dig.getAction() == DiggingAction.DROP_ITEM) {
ItemStack heldItem = getHeldItem();
if (heldItem != null) {
heldItem.setAmount(heldItem.getAmount() - 1);
if (heldItem.getAmount() <= 0) {
heldItem = null;
}
}
inventory.setHeldItem(heldItem);
inventory.getInventoryStorage().handleClientClaimedSlotSet(Inventory.HOTBAR_OFFSET + player.packetStateData.lastSlotSelected);
}
if (dig.getAction() == DiggingAction.DROP_ITEM_STACK) {
inventory.setHeldItem(null);
inventory.getInventoryStorage().handleClientClaimedSlotSet(Inventory.HOTBAR_OFFSET + player.packetStateData.lastSlotSelected);
}
} else if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_CHANGE) {
final int slot = new WrapperPlayClientHeldItemChange(event).getSlot();
// Stop people from spamming the server with an out-of-bounds exception
if (slot > 8 || slot < 0) return;
// set this before we change the selected slot so we get the previous item held
this.startOfTickStack = getHeldItem();
inventory.setSelected(slot);
} else if (event.getPacketType() == PacketType.Play.Client.CREATIVE_INVENTORY_ACTION) {
WrapperPlayClientCreativeInventoryAction action = new WrapperPlayClientCreativeInventoryAction(event);
if (player.gamemode != GameMode.CREATIVE) return;
boolean valid = action.getSlot() >= 1 &&
(PacketEvents.getAPI().getServerManager().getVersion().isNewerThan(ServerVersion.V_1_8) ?
action.getSlot() <= 45 : action.getSlot() < 45);
if (valid) {
inventory.getSlot(action.getSlot()).set(action.getItemStack());
inventory.getInventoryStorage().handleClientClaimedSlotSet(action.getSlot());
}
} else if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW && !event.isCancelled()) {
WrapperPlayClientClickWindow click = new WrapperPlayClientClickWindow(event);
// How is this possible? Maybe transaction splitting.
if (click.getWindowId() != openWindowID) {
return;
}
// Don't care about this click since we can't track it.
if (menu instanceof NotImplementedMenu) {
return;
}
// Mark the slots the player has changed as changed, then continue simulating what they changed
Optional<Map<Integer, ItemStack>> slots = click.getSlots();
slots.ifPresent(integerItemStackMap -> integerItemStackMap.keySet().forEach(this::markPlayerSlotAsChanged));
// 0 for left click
// 1 for right click
int button = click.getButton();
// Offset by the number of slots in the inventory actively open
// Is -999 when clicking off the screen
int slot = click.getSlot();
// Self-explanatory, look at the enum's values
WrapperPlayClientClickWindow.WindowClickType clickType = click.getWindowClickType();
if (slot == -1 || slot == -999 || slot < menu.getSlots().size()) {
menu.doClick(button, slot, clickType);
}
} else if (event.getPacketType() == PacketType.Play.Client.CLOSE_WINDOW) {
this.closeActiveInventory();
} else if (isTickPacket(event.getPacketType())) {
this.startOfTickStack = getHeldItem();
}
}
public void markSlotAsResyncing(BlockPlace place) {
// Update held item tracking
if (place.hand == InteractionHand.MAIN_HAND) {
inventory.getInventoryStorage().handleClientClaimedSlotSet(Inventory.HOTBAR_OFFSET + player.packetStateData.lastSlotSelected);
} else {
inventory.getInventoryStorage().handleServerCorrectSlot(Inventory.SLOT_OFFHAND);
}
}
public void onBlockPlace(BlockPlace place) {
if (player.gamemode != GameMode.CREATIVE && place.itemStack.getType() != ItemTypes.POWDER_SNOW_BUCKET) {
markSlotAsResyncing(place);
place.itemStack.setAmount(place.itemStack.getAmount() - 1);
}
}
@Override
public void onPacketSend(final PacketSendEvent event) {
// Not 1:1 MCP, based on Wiki.VG to be simpler as we need less logic...
// For example, we don't need permanent storage, only storing data until the client closes the window
// We also don't need a lot of server-sided only logic
if (event.getPacketType() == PacketType.Play.Server.OPEN_WINDOW) {
WrapperPlayServerOpenWindow open = new WrapperPlayServerOpenWindow(event);
MenuType menuType = MenuType.getMenuType(open.getType());
AbstractContainerMenu newMenu;
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_14)) {
newMenu = MenuType.getMenuFromID(player, inventory, menuType);
} else {
newMenu = MenuType.getMenuFromString(player, inventory, open.getLegacyType(), open.getLegacySlots(), open.getHorseId());
}
packetSendingInventorySize = newMenu instanceof NotImplementedMenu ? UNSUPPORTED_INVENTORY_CASE : newMenu.getSlots().size();
// There doesn't seem to be a check against using 0 as the window ID - let's consider that an invalid packet
// It will probably mess up a TON of logic both client and server sided, so don't do that!
player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
openWindowID = open.getContainerId();
menu = newMenu;
isPacketInventoryActive = !(newMenu instanceof NotImplementedMenu);
needResend = newMenu instanceof NotImplementedMenu;
});
}
// I'm not implementing this lol
if (event.getPacketType() == PacketType.Play.Server.OPEN_HORSE_WINDOW) {
WrapperPlayServerOpenHorseWindow open = new WrapperPlayServerOpenHorseWindow(event);
packetSendingInventorySize = UNSUPPORTED_INVENTORY_CASE;
player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
isPacketInventoryActive = false;
needResend = true;
openWindowID = open.getWindowId();
});
}
// 1:1 MCP
if (event.getPacketType() == PacketType.Play.Server.CLOSE_WINDOW) {
packetSendingInventorySize = PLAYER_INVENTORY_CASE;
// Disregard provided window ID, client doesn't care...
// We need to do this because the client doesn't send a packet when closing the window
player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), this::closeActiveInventory);
}
// Should be 1:1 MCP
if (event.getPacketType() == PacketType.Play.Server.WINDOW_ITEMS) {
WrapperPlayServerWindowItems items = new WrapperPlayServerWindowItems(event);
stateID = items.getStateId();
List<ItemStack> slots = items.getItems();
for (int i = 0; i < slots.size(); i++) {
markServerForChangingSlot(i, items.getWindowId());
}
final int cachedPacketInvSize = packetSendingInventorySize;
final AtomicBoolean updatedValue = new AtomicBoolean();
player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
// Never true when the inventory is unsupported.
// Vanilla ALWAYS sends the entire inventory to resync, this is a valid thing to check
// 01/07/2025: Somehow, the server sends a window id 0 update when the player is not in their inventory?
// I guess just revert isPacketInventoryActive if the player has a NotImplementedMenu open?
// Regardless, the client does accept this packet and updates its inventory, so we must do the same.
boolean forceUpdate = slots.size() == cachedPacketInvSize || items.getWindowId() == 0;
if (!isPacketInventoryActive && forceUpdate) {
isPacketInventoryActive = true;
updatedValue.set(true);
}
});
if (items.getWindowId() == 0) { // Player inventory
player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
if (!isPacketInventoryActive) return;
for (int i = 0; i < slots.size(); i++) {
inventory.getSlot(i).set(slots.get(i));
}
if (items.getCarriedItem().isPresent()) {
inventory.setCarried(items.getCarriedItem().get());
}
});
} else {
player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
if (!isPacketInventoryActive) return;
if (items.getWindowId() == openWindowID) {
for (int i = 0; i < slots.size(); i++) {
menu.getSlot(i).set(slots.get(i));
}
}
if (items.getCarriedItem().isPresent()) {
inventory.setCarried(items.getCarriedItem().get());
}
});
}
player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
// The server sent a packet for the player's inventory when they had another inventory open - revert.
if (updatedValue.get() && !menu.equals(inventory)) {
isPacketInventoryActive = false;
}
});
}
// This packet replaces SET_SLOT for player inventory for 1.21.2+
if (event.getPacketType() == PacketType.Play.Server.SET_PLAYER_INVENTORY) {
WrapperPlayServerSetPlayerInventory slot = new WrapperPlayServerSetPlayerInventory(event);
final int slotID = slot.getSlot();
final ItemStack item = slot.getStack();
inventory.getInventoryStorage().handleServerCorrectSlot(slotID);
player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
if (!isPacketInventoryActive) return;
inventory.getSlot(slotID).set(item);
});
}
// Also 1:1 MCP
if (event.getPacketType() == PacketType.Play.Server.SET_SLOT) {
// Only edit hotbar (36 to 44) if window ID is 0
// Set cursor by putting -1 as window ID and as slot
// Window ID -2 means any slot can be used
WrapperPlayServerSetSlot slot = new WrapperPlayServerSetSlot(event);
final int slotID = slot.getSlot();
final int inventoryID = slot.getWindowId();
final ItemStack item = slot.getItem();
if (inventoryID == -2) { // Direct inventory change
inventory.getInventoryStorage().handleServerCorrectSlot(slotID);
} else if (inventoryID == 0) { // Inventory change through window ID, no crafting result
inventory.getInventoryStorage().handleServerCorrectSlot(slotID);
} else {
markServerForChangingSlot(slotID, inventoryID);
}
stateID = slot.getStateId();
player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
if (!isPacketInventoryActive) return;
if (inventoryID == -1) { // Carried item
inventory.setCarried(item);
} else if (inventoryID == -2) { // Direct inventory change (only applied if valid slot)
if (inventory.getInventoryStorage().getSize() > slotID && slotID >= 0) {
inventory.getInventoryStorage().setItem(slotID, item);
}
} else if (inventoryID == 0) { // Player inventory
// This packet can only be used to edit the hotbar and offhand of the player's inventory if
// window ID is set to 0 (slots 36 through 45) if the player is in creative, with their inventory open,
// and not in their survival inventory tab. Otherwise, when window ID is 0, it can edit any slot in the player's inventory.
if (slotID >= 0 && slotID <= 45) {
inventory.getSlot(slotID).set(item);
}
} else if (inventoryID == openWindowID) { // Opened inventory (if not valid, client crashes)
menu.getSlot(slotID).set(item);
}
});
}
}
/**
* Closes the player's currently open inventory on the client by resetting to the player's inventory.
*/
private void closeActiveInventory() {
isPacketInventoryActive = true;
openWindowID = 0;
menu = inventory;
menu.setCarried(ItemStack.EMPTY); // Reset carried item
}
}
// NOTE (AI): The class implements PacketReceiveListener and PacketSendListener and is the largest inventory-state consumer in Grim. The WINDOW_ITEMS handling validates the dump size against the open window before applying it, and window id 0 always re-enables packet-inventory mode.Model the server's window-items send as a typed nayoro event so Intave's inventory tracking can react to full window dumps.
WindowItemsEvent carries the window id, the slot count, and a map of slot to item. It is one of the event types dispatched through the nayoro EventSink visitor, and the protocol layer registers it in the event registry. The class also handles item serialization for the nayoro wire format.
// ===== FILE: intave-intave, src/main/java/de/jpx3/intave/module/nayoro/event/WindowItemsEvent.java =====
package de.jpx3.intave.module.nayoro.event;
import de.jpx3.intave.module.nayoro.Environment;
import de.jpx3.intave.module.nayoro.Inventory;
import de.jpx3.intave.module.nayoro.event.sink.EventSink;
import org.bukkit.inventory.ItemStack;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public final class WindowItemsEvent extends Event {
private int windowId;
private int count;
private final Map<Integer, Inventory.Item> items = new HashMap<>();
public WindowItemsEvent() {
}
public WindowItemsEvent(
int windowId, int count,
Map<Integer, ItemStack> items
) {
this.windowId = windowId;
this.count = count;
for (Map.Entry<Integer, ItemStack> entry : items.entrySet()) {
int slot = entry.getKey();
this.items.put(slot, Inventory.Item.fromItem(entry.getValue()));
}
}
@Override
public void serialize(Environment environment, DataOutput out) throws IOException {
out.writeInt(windowId);
out.writeInt(count);
out.writeInt(items.size());
for (Map.Entry<Integer, Inventory.Item> entry : items.entrySet()) {
out.writeInt(entry.getKey());
entry.getValue().serialize(out);
}
}
@Override
public void deserialize(Environment environment, DataInput in) throws IOException {
windowId = in.readInt();
count = in.readInt();
if (count > 1024) {
throw new IOException("Too many items: " + count);
}
items.clear();
int size = in.readInt();
if (size > 1024) {
throw new IOException("Too many items: " + size);
}
for (int i = 0; i < size; i++) {
int slot = in.readInt();
items.put(slot, Inventory.Item.deserialize(in));
}
}
@Override
public void accept(EventSink sink) {
sink.visit(this);
}
public int windowId() {
return windowId;
}
public int count() {
return count;
}
public Map<Integer, Inventory.Item> items() {
return items;
}
public void addItem(int slot, Inventory.Item item) {
items.put(slot, item);
}
public void removeItem(int index) {
items.remove(index);
}
public void clearItems() {
items.clear();
}
public static WindowItemsEvent create(
int windowId, int slots, Map<Integer, ItemStack> items
) {
return new WindowItemsEvent(windowId, slots, items);
}
}
// NOTE (AI): The nayoro module is Intave's server-side inventory event abstraction; the WindowItemsEvent mirrors the vanilla window-items send so downstream visitors receive a typed slot map instead of raw packets.Related Packets
Wiki Cross-Reference
Clientbound 0x30: unsigned byte windowId, short slot count, then ItemStack per slot.
Window 0 dumps player inventory; container dump follows S2D open back to back.
Also sent as recovery when a C0E click is rejected, forcing client to revert slots.
MCP 1.8.9 S30PacketWindowItems implements Packet
1.8.9 callers: EntityPlayerMP.updateCraftingInventory sends new S30PacketWindowItems (line 875): 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 S30PacketWindowItems
Full source walkthroughs of the modules and anti-cheats that use this packet.