Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not remapping Fabric mods correctly #7

Open
RafaeloxMC opened this issue Mar 6, 2024 · 6 comments
Open

Not remapping Fabric mods correctly #7

RafaeloxMC opened this issue Mar 6, 2024 · 6 comments

Comments

@RafaeloxMC
Copy link

RafaeloxMC commented Mar 6, 2024

Hey,
while coding my fabric mod, I found this repo and noticed that it would be quite helpful. I wrote an extra little program to remap my mod using the TinyRemapperEngine. My problem is, that it's only remapping class names, not method names. (Example: public void render(class_332 context, int mouseX, int mouseY, float delta) should be public void method_25394(class_332 context, int mouseX, int mouseY, float delta) - as you can already see here, the context got remapped correctly, the method name didnt.)

This is the code that I used for my remapper:

package dev.xvcf;

import com.pocolifo.jarremapper.JarRemapper;
import com.pocolifo.jarremapper.extensions.TinyRemapperEngine;
import com.pocolifo.jarremapper.mapping.JarMapping;
import com.pocolifo.jarremapper.reader.tiny.Tiny2MappingReader;

import java.io.File;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        System.out.println("TinyV2 Jar Remapper by xvcf using Pocolifo's Jar Remapper (https://github.com/pocolifo/jar-remapper/)!");

        JarMapping mappings;

        String from = "named";
        String to = "intermediary";

        String mappingsFile = "./run/mappings.tiny";

        System.out.println("Using mappings from: " + mappingsFile);

        mappings = new Tiny2MappingReader(
                new File(mappingsFile)
        ).read(from, to);

        String inputJar = "./run/input.jar";
        String outputJar = "./run/output.jar";

        File inputJarFile = new File(inputJar);
        if (!inputJarFile.exists()) {
            System.out.println("Input jar not found: " + inputJar);
            return;
        }

        File outputJarFile = new File(outputJar);
        if (outputJarFile.exists()) {
            System.out.println("Output jar already exists, deleting it...");
            outputJarFile.delete();
        }

        JarRemapper.newRemap()
                .withInputFile(inputJarFile)
                .withOutputFile(new File(outputJar))
                .withMappings(mappings)
                .withRemappingEngine(new TinyRemapperEngine())
                .overwriteOutputFile()
                .remap();

        System.out.println("Remapped from " + from + " to " + to + "! Saved to " + outputJar);
    }
}

Is it just my stupidity or is this a bug?

Thank you for your time,
Have a nice day!

@YoungerMax
Copy link
Member

Hey,

I'm so glad you found my repo helpful and thanks for using it!

Could you provide the class header of the class that the render method is in? I'm interested in if you're implementing/extending another interface/class.

Thanks again!

@RafaeloxMC
Copy link
Author

Indeed I am. This was the render method in a custom screen which I use for my mod. The screen is just a pretty simple login screen

public class LoginScreen extends Screen {
    public LoginScreen() {
        super(Text.of("Log in"));
    }

    @Override
    public void render(DrawContext context, int mouseX, int mouseY, float delta) {
        this.renderBackground(context, mouseX, mouseY, delta);
        super.render(context, mouseX, mouseY, delta);
    }
// ...
}

Thank you for the quick response!

@RafaeloxMC
Copy link
Author

I just checked my code again and I saw that the remapped jar file from the project actually gets remapped correctly (all methods, fields, classes, ...)
So there must be a problem either in TinyRemapper (by Fabric, I didnt get it to work with that either, same problem) or its a problem with the way I used it

@YoungerMax
Copy link
Member

It could also be that Tiny2MappingReader is not reading that part of the mappings file. What tiny mappings are you using from Fabric/what version?

@RafaeloxMC
Copy link
Author

RafaeloxMC commented Mar 8, 2024

I am using the mappings from IntelliJ's external libraries
image
I uploaded this mappings file here:
mappings.txt
(this was a .tiny file but GitHub didn't allow me to upload .tiny, just change the file extension)

Fabric version information (from gradle.properties):

minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.7
# this is fabric api
fabric_version=0.96.4+1.20.4

@YoungerMax
Copy link
Member

Hey,

Many, many apologies for the late reply. I finally had some time to look into this, and I can confirm that Tiny2MappingReader is reading the mappings correctly. So, I've pushed a commit (9e07ca6) which updates Tiny Remapper to version 0.9.0. Let me know if this works--fingers crossed it does--but please do get back to me if it doesn't.

Apologies again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants