Alvinn8 / paper-nms-maven-plugin

A maven plugin for using NMS on paper with Mojang mappings.
MIT License
115 stars 8 forks source link

Support 1.16 and below #2

Open Alvinn8 opened 2 years ago

Alvinn8 commented 2 years ago

On some older spigot versions, mappings use a package rename to avoid having to retype net/minecraft/server for every class mapping. Lorenz does not support package renames in srg mapping files (SrgReader.java#L134-L135) so we will need to copy the package over to all classes before reading the mappings. Or is there a better solution?

By1337 commented 2 months ago

Hi!

I’ve implemented support for versions 1.14.4 -> 1.16.5 in my Maven plugin BNms-plugin.

Here are the challenges I had to address:

  1. Reading the mappings:

    • I didn’t use any external libraries for reading the mappings. Parsing csrg mappings was relatively straightforward, but proGuard mappings presented some difficulties. To convert them to csrg, I had to build an inheritance map in both directions (from kid to super and vice versa).
  2. Reverting bukkit-1.16.5-cl.csrg:

    • The main issue was handling the relocation. However, I managed to solve it since the pattern was known for all non-NMS classes. For NMS classes, I simply read the mappings and created the corresponding map (AdvancementProgress -> net/minecraft/advancements/).
  3. Applying Mojang mappings:

    • Working with classes went smoothly, but I encountered issues with members due to the obf helper. However, since I had already built the inheritance map while parsing proGuard mappings, this made it easier to check for name conflicts.

It’s also worth mentioning that until version 1.16, all NMS classes were located in a single package, which violated the encapsulation of package-private members. Restoring the original NMS structure leads to issues with running the server due to unauthorized access.

By1337 commented 2 months ago

I would appreciate it if you could mention that there is a solution available for versions 1.16.5 and below.