ProtocolLib

3M Downloads

unable to get the byte array of chunk packet

ham1255 opened this issue ยท 1 comments

commented

Make sure you're doing the following

  • You're using the latest build for your server version
  • This isn't an issue caused by another plugin
  • You've checked for duplicate issues
  • You didn't use /reload

Describe the question
has chunk packet contains an byte array for chunk data as per wiki.vg
so created that code can be seen below , to get that packet. then getting byte array
which throws com.comphenix.protocol.reflect.FieldAccessException: Field index 0 is out of bounds for length 0
due fact getByteArrays is empty.

API method(s) used
PacketContainer#getByteArrays()
StructureModifier#read(int fieldIndex)

Expected behavior
should return the byte array?

Code

protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.LOWEST, PacketType.Play.Server.MAP_CHUNK) {
            @Override
            public void onPacketSending(PacketEvent event) {
                byte[] data = event.getPacket().getByteArrays().read(0);
            }
        });
commented

This format with a simple byte array is obsolete, see #1592