ProtocolLib

3M Downloads

Exception with SlotStackPairs

MCMDEV opened this issue ยท 1 comments

commented

Describe the bug
When trying to use pairs of SlotStackPairs using packet.getSlotStackPairLists(), the server throws ClassCastExceptions.

To Reproduce
Steps to reproduce the behavior:

  1. Create ProtocolListener which listens to every outgoing packet
  2. Modify every field of the type, I did it this way:
    @Override
    public void onPacketSending(PacketEvent event) {
        PacketContainer packet = event.getPacket();
        for (int i = 0; i < packet.getSlotStackPairLists().getFields().size(); i++) {
            packet.getSlotStackPairLists().modify(i, input -> input);
        }
    }
3. Watch it break

Expected behavior
Nothing

Logs
latest.log

Version Info
https://pastebin.com/GCMWG4NY

commented

The method getSlotStackPairLists will return all fields of type List which does not mean that a slot pair is in it (applies to all modifiers with a generic parameter). You have to verify yourself which fields you are modifying.

Btw in the MapChunk packet is never a SlotStack List :)