aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/internal/init/OneConfigInit.java
blob: 4d80f4d0892befa86505e20c077e4e0d50b32631 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package cc.polyfrost.oneconfig.internal.init;

import net.minecraft.launchwrapper.Launch;
import org.spongepowered.asm.launch.MixinBootstrap;
import org.spongepowered.asm.mixin.Mixins;

import java.io.File;
import java.util.jar.JarFile;
import java.util.jar.Manifest;

@SuppressWarnings("unused")
public class OneConfigInit {

    public static void initialize(String[] args) {
        Launch.blackboard.put("oneconfig.initialized", true);
        MixinBootstrap.init();
        if (Launch.blackboard.containsKey("oneconfig.wrapper.modFile")) {
            try {
                File modFile = (File) Launch.blackboard.get("oneconfig.wrapper.modFile");
                try (JarFile jarFile = new JarFile(modFile)) {
                    Manifest manifest = jarFile.getManifest();
                    if (manifest != null) {
                        String mixinConfigs = manifest.getMainAttributes().getValue("MixinConfigs");
                        if (mixinConfigs != null) {
                            Mixins.addConfiguration(mixinConfigs);
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        Mixins.addConfiguration("mixins.oneconfig.json");
    }
}