Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6516

Fields in NMS packets are final!


    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Major Major
    • None
    • None
    • This is likely one of the first 1.17 builds. I am using Linux Manjaro GNOME. Server is obviously using Java 16 Azul Zulu.

    • This server is running CraftBukkit version 3111-Spigot-66f9d3c-cbf2f67 (MC: 1.17) (Implementing API version 1.17-R0.1-SNAPSHOT)
    • Yes

      In 1.16.5 and all older server versions, fields in NMS packets were NOT final. Which allowed packet listeners (which process incoming and outgoing packets) to modify the data in the packets. Most packet listeners add their netty handlers before the minecraft server. If I modify the data of an incoming packet(server-bound), the vanilla server would process the modified packet. The same applies to outgoing packets, we could modify packets the server was planning to send. This was great, until 1.17. I haven't confirmed that this is the case in all packets, but all the ones I have looked at have had final fields. With reflection we can no longer modify fields. Using unsafe API or some weird java hacks is not really an end solution to this. Spigot can change this for future builds. I understand if you were trying to do some optimizations to the NMS packets, but this is a breaking change for popular plugins like ProtocolLib and my library (packetevents) too.


      Edit: Reflection allows you to modify final fields, as long as they are not "static final", but "final" itself works.

            Unassigned Unassigned
            retrooper retrooper
            0 Vote for this issue
            4 Start watching this issue