egametang/ET · critical
slot index {slotIndex} exceeds capacity {self.Capacity}
Error message
slot index {slotIndex} exceeds capacity {self.Capacity} What it means
Thrown by the CLIENT-side ItemComponentSystem.EnsureSlotIndex when a slot index is >= the bag's Capacity. EnsureSlotIndex guards UpdateItem and SetSlotItem on the client. The client bag defaults to capacity 100 (Awake), so any server-pushed slotIndex at or above that ceiling trips this guard. It is a hard invariants check, not a recoverable runtime state — the client expects the server to only ever reference slots that already exist locally.
Source
Thrown at Packages/cn.etetet.item/Scripts/Hotfix/Client/ItemComponentSystem.cs:204
}
self.SlotItems[slotIndex] = default;
}
#endregion
#region 私有方法
private static void EnsureSlotIndex(ItemComponent self, int slotIndex)
{
if (slotIndex < 0)
{
throw new Exception($"invalid slot index: {slotIndex}");
}
if (slotIndex >= self.Capacity)
{
throw new Exception($"slot index {slotIndex} exceeds capacity {self.Capacity}");
}
}
private static void EnsureSlotContainerSize(ItemComponent self, int size)
{
if (size <= 0)
{
return;
}
if (self.SlotItems.Count >= size)
{
return;
}
int addCount = size - self.SlotItems.Count;
for (int i = 0; i < addCount; ++i)
{View on GitHub (pinned to 5cab01f7a8)
Solutions
- Ensure the server sends and the client applies M2C_UpdateBagCapacity (which calls Client SetCapacity) BEFORE any M2C_UpdateItem referencing the new slots.
- Check self.Capacity client-side before calling UpdateItem/SetSlotItem and, if the index is out of range, force a full bag sync from the server.
- Verify the serialized Capacity value is identical on server and client after a hot-reload or rebuild.
- Stop passing hand-computed slot indices; always obtain them from FindEmptySlot / server-authoritative data.
Example fix
// before — server grows bag then immediately pushes item at new slot ItemHelper.SetCapacity(component, 120); NotifyItemUpdate(component, itemAtSlot115); // after — capacity message is flushed/ordered before item updates ItemHelper.SetCapacity(component, 120); // sends M2C_UpdateBagCapacity // ensure client applies capacity change (flush/ordered send) before item updates NotifyItemUpdate(component, itemAtSlot115);
Defensive patterns
Strategy: validation
Validate before calling
// Client: before applying a server item update, ensure the slot exists locally.
public static void SafeUpdateItem(this ItemComponent self, long itemId, int slotIndex, int configId, int count)
{
if (slotIndex < 0 || slotIndex >= self.Capacity)
{
Log.Error($"reject item update: slot {slotIndex} out of range (cap {self.Capacity}); requesting full sync");
// trigger a server re-sync of the bag here
return;
}
self.UpdateItem(itemId, slotIndex, configId, count);
} Prevention
- Always send M2C_UpdateBagCapacity before any item update that targets a new slot.
- Never cache Capacity; read self.Capacity at the point of use.
- After a hot-reload/rebuild, force a full bag resync to reconcile server/client capacity.
When it happens
Trigger: A server-to-client M2C_UpdateItem message carries a SlotIndex >= self.Capacity, and Client ItemComponentSystem.UpdateItem (line 35) calls EnsureSlotIndex before placing the item. Also reached via Client SetSlotItem (line 169). Happens when the server expanded capacity (SetCapacity) and pushed items into new slots before the M2C_UpdateBagCapacity message was applied client-side, or when client Capacity was never grown to match.
Common situations: Server/client capacity desync after server grows the bag; ordering bug where item updates arrive before the capacity-update message; a serialized Capacity that differs between server and client rebuilds; a custom caller passing a literal slot index without checking Capacity first.
Related errors
- slot index {slotIndex} exceeds capacity {self.Capacity}
- invalid capacity: {capacity}
- invalid slot index: {slotIndex}
- bag is full
- invalid item count
AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13).
Data as JSON: /api/errors/60e2fc7d6f539193.
Report an issue: GitHub.