MaxPixelStudios / MinecraftDecompiler

Minecraft Decompiler. A useful tool/library to deobfuscate and decompile Minecraft(or any jar file) through popular mappings and various decompilers. Or use it as a lib to process obfuscation mappings such as converting a mapping to another format
GNU General Public License v3.0
327 stars 19 forks source link

[BUG] [3.3.2] Nested public classes are not decompiled. #145

Closed thomas-ej-worm closed 5 months ago

thomas-ej-worm commented 5 months ago

Describe the bug

Hello,

I want to decompile the MC source with

java -jar MinecraftDecompiler --decompile fernflower -r --version 1.20.6 -s SERVER

There are some decompiling problems like varargs getting prefixed with array type like
(Object[]) (object1, object2, object3)
which leads to compiling failures. I think these are FernFlower issues.

But the problem I mostly am faced with is that nested public classes are not decompiled.
E.g. in the deobfuscated jar there are NaturalSpawner$SpawnState.class or AnyBlockInteractionTrigger$TriggerInstance.class.

It seems that all classes with $ in name are ignored. So a lot code is missing in the decompiled code.

To Reproduce Steps to reproduce the behavior:

  1. Run java -jar MinecraftDecompiler --decompile fernflower -r --version 1.20.6 -s SERVER
  2. Look for NaturalSpawner.SpawnState in decompiled code.
  3. It's missing!

Expected behavior Nested classes will be present!

System Info:

XiaoPangxie732 commented 5 months ago

then im guessing this is also a fernflower issue. try decompiling with the default decompiler(simply replace --decompile fernflower with --decompile or -d)

thomas-ej-worm commented 5 months ago

Thanks. This solved nested classes not getting decompiled but leads to other problems.

E.g. in com.mojang.math.OctahedralGroup the renamed local variables (method parameters) are not decompiled correctly:

private OctahedralGroup(final String param3, final SymmetricGroup3 param4, final boolean param5, final boolean param6, final boolean param7) {
      this.name = s;
      this.invertX = flag;
      this.invertY = flag1;
      this.invertZ = flag2;
      this.permutation = symmetricgroup3;
      this.transformation = new Matrix3f().scaling(flag ? -1.0F : 1.0F, flag1 ? -1.0F : 1.0F, flag2 ? -1.0F : 1.0F);
      this.transformation.mul(symmetricgroup3.transformation());
   }

s, flag, and so on are unknown symbols, because function parameters are called paramX.

With using FernFlower as decompiler the rename option of MinecraftDecompiler is handled correctly:

private OctahedralGroup(final String s, final SymmetricGroup3 symmetricgroup3, final boolean flag, final boolean flag1, final boolean flag2) {
        this.name = s;
        this.invertX = flag;
        this.invertY = flag1;
        this.invertZ = flag2;
        this.permutation = symmetricgroup3;
        this.transformation = (new Matrix3f()).scaling(flag ? -1.0F : 1.0F, flag1 ? -1.0F : 1.0F, flag2 ? -1.0F : 1.0F);
        this.transformation.mul(symmetricgroup3.transformation());
    }
XiaoPangxie732 commented 5 months ago

https://github.com/MaxPixelStudios/MinecraftDecompiler/actions/runs/9148385977 you can download and use the artifact in this run this version uses an updated version of vineflower

XiaoPangxie732 commented 5 months ago

an alternative is to use the user-defined decompiler: put the config file at decompiler/decompiler.properties follow the config file and put your decompiler jar at the right path

decompiler.txt github doesn't allow uploading .properties files, you need to rename it yourself

if you did everything right, you will get something like this except that vineflower is version 1.10.1 image then replace arg -d with -d user-defined and run mcd

XiaoPangxie732 commented 5 months ago

Close as this is a decompiler error, which is not the problem on this project's end.

Integrated decompilers may be outdated, but you can use their latest version through the user-defined decompiler feature.