egametang/ET · error
slot index exceeds capacity
Error message
slot index {slotIndex} exceeds capacity {self.Capacity} What it means
Thrown by the SERVER-side ItemComponentSystem.EnsureSlotIndex when slotIndex >= self.Capacity (the second guard, after the negative check). This is the server-side twin of error 200. The server bag defaults to Capacity 100 (Awake, line 17), so any index at or above the current capacity is rejected before writing SlotItems.
Solutions
- Grow Capacity via SetCapacity before placing items at higher indices.
- When shrinking capacity, first move/evict items in slots >= new Capacity (the code currently never shrinks SlotItems, so a manual remap is required).
- Always read self.Capacity at call time rather than caching it.
Example fix
// before component.SetSlotItem(115, item); // Capacity still 100 // after if (component.Capacity <= 115) component.SetCapacity(120); component.SetSlotItem(115, item);
Defensive patterns
Strategy: validation
Validate before calling
if (slotIndex < 0 || slotIndex >= component.Capacity)
{
Log.Error($"slot {slotIndex} invalid for capacity {component.Capacity}");
return;
}
component.SetSlotItem(slotIndex, item); Prevention
- Grow Capacity before placing items at higher indices.
- When shrinking, remap items out of the truncated range first.
- Read self.Capacity live; do not trust a stale cached value.
When it happens
Trigger: Server code calls SetSlotItem with an index that was valid under a larger capacity but the bag was shrunk, or a caller computed an index from a stale/config capacity that exceeds the live Capacity. Also triggered if SetCapacity is never called to grow the bag before placing items beyond the default 100.
Common situations: Capacity shrink without re-mapping existing items; a config change lowering the bag size while items still occupy high slots; server logic that assumes a bigger bag than was actually allocated.
Related errors
AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13).
Data as JSON: /api/errors/7568b24089cf46ea.
Report an issue: GitHub.
Appendix: source
Thrown at Packages/cn.etetet.item/Scripts/Hotfix/Server/ItemComponentSystem.cs:205
{
if ((uint)slotIndex < (uint)self.SlotItems.Count)
{
return self.SlotItems[slotIndex];
}
return null;
}
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)