I'm using 1.18.2, forge version 40.1.0. I have encountered this IndexOutOfBoundsException when sending packets to the client at the wrong time (during a dimension switch, when dead, or on login). If anyone has any insight, I'd love to hear it.
Here's the example mod created to replicate the error (using the PlayerChangedDimensionEvent):
The client log:
The server log: