dmulloy2 / ProtocolLib

Provides read and write access to the Minecraft protocol with Bukkit.
GNU General Public License v2.0
980 stars 257 forks source link

Inconsistent packet handlers with ProtocolLib versions #3013

Open Olzie-12 opened 1 week ago

Olzie-12 commented 1 week ago

Describe the bug Very inconsistent packet containers, upon using 5.2.0. The OPEN_SIGN_EDITOR works just fine. I used some debug and this is what it prints in console.

PacketContainer[type=OPEN_SIGN_EDITOR[class=PacketPlayOutOpenSignEditor, id=50], structureModifier=StructureModifier[fieldType=class java.lang.Object, data=[com.comphenix.protocol.reflect.accessors.DefaultFieldAccessor@3c483959, com.comphenix.protocol.reflect.accessors.DefaultFieldAccessor@7f3fd91f]]]
[00:09:28 INFO]: net.minecraft.network.protocol.game.PacketPlayOutOpenSignEditor@2b10a187
[00:09:28 INFO]: OPEN_SIGN_EDITOR[class=PacketPlayOutOpenSignEditor, id=50]

with code:

   PacketContainer openSign = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.OPEN_SIGN_EDITOR);
                System.out.println(openSign);
                System.out.println(openSign.getHandle());
                System.out.println(openSign.getType());

The sign opens just fine. Now when I switch over to the dev build: 5.3.0 # 720 build, the console prints this.

PacketContainer[type=OPEN_SIGN_EDITOR[class=PacketStatusOutPong, id=52], structureModifier=StructureModifier[fieldType=class java.lang.Object, data=[com.comphenix.protocol.reflect.accessors.DefaultFieldAccessor@707c35ec]]]
[00:07:21 INFO]: net.minecraft.network.protocol.status.PacketStatusOutPong@372b5dfb
[00:07:21 INFO]: OPEN_SIGN_EDITOR[class=PacketStatusOutPong, id=52]

Now the issue with this is, for some reason the handle is PacketStatusOutPong? I am using server version 1.20.4, Paper. It won't let me send the sign editor because its saying:

[23:27:44 WARN]: FieldAccessException: Field index 0 is out of bounds for length 0
[23:27:44 WARN]:        at ProtocolLib.jar//com.comphenix.protocol.reflect.FieldAccessException.fromFormat(FieldAccessException.java:49)
[23:27:44 WARN]:        at ProtocolLib.jar//com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:315)

When trying to write the block position modifier, I assume its because its not using the right handler.

dmulloy2 commented 1 week ago

interesting. does this happen in listeners or just when creating?

Olzie-12 commented 1 week ago

interesting. does this happen in listeners or just when creating?

well as far as i know it’s just from creating, it’s when i’m creating packet container and then applying correct meta to it

dmulloy2 commented 1 week ago

makes sense. was just wondering if you'd seen it in the listeners as well. would point to a larger issue. i'll look into this. have a few theories as to what's going on here

dmulloy2 commented 1 week ago

i was able to reproduce this and thankfully it's specific to OPEN_SIGN_EDITOR in 1.20.4. now to figure out exactly why

Olzie-12 commented 5 days ago

Any updates on this, is this still an ongoing issue?