Jump to content

I tried loading mod without @Mod annotation but I need some help


Vert3xo

Recommended Posts

Hello, so title says it all. I tried creating a mod without @ Mod annotation by extending the main class with DummyModContainer. My code looks like this:

TestMod.java (Main class)

package me.vert3xo.testmod;

import com.google.common.eventbus.EventBus;
import net.minecraftforge.fml.common.DummyModContainer;
import net.minecraftforge.fml.common.LoadController;
import net.minecraftforge.fml.common.ModMetadata;

import java.util.Collections;

public class TestMod extends DummyModContainer {

    public static final String MOD_ID = "testmod";
    public static final String MOD_NAME = "Test Mod";
    public static final String VERSION = "1.0";

    public TestMod() {
        super(new ModMetadata());
        ModMetadata meta = getMetadata();
        meta.modId = MOD_ID;
        meta.name = MOD_NAME;
        meta.version = VERSION;
        meta.authorList = Collections.singletonList("Vert3xo");
    }

    @Override
    public boolean registerBus(EventBus bus, LoadController controller) {
        return true;
    }

}

ModLoader.java (implements IFMLLoadingPlugin)

package me.vert3xo.testmod;

import me.vert3xo.testmod.asm.ClassTransformer;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;

import java.util.Map;

@IFMLLoadingPlugin.Name("Test Mod")
@IFMLLoadingPlugin.MCVersion("1.8.9")
public class ModLoader implements IFMLLoadingPlugin {
    @Override
    public String[] getASMTransformerClass() {
        return new String[]{
                ClassTransformer.class.getName()
        };
    }

    @Override
    public String getModContainerClass() {
        return TestMod.class.getName();
    }

    @Override
    public String getSetupClass() {
        return null;
    }

    @Override
    public void injectData(Map<String, Object> data) {

    }

    @Override
    public String getAccessTransformerClass() {
        return null;
    }
}

ClassTransformer.java (implements IClassTransformer)

package me.vert3xo.testmod.asm;

import net.minecraft.launchwrapper.IClassTransformer;

public class ClassTransformer implements IClassTransformer {
    @Override
    public byte[] transform(String s, String s1, byte[] bytes) {
        return new byte[0];
    }
}

And I have also added this to my build.gradle (copied it from MouseDelayFix mod)

jar
        {
            manifest
                    {
                        attributes("FMLCorePlugin": "me.vert3xo.testmod.ModLoader")
                    }
        }

With this ^ in my build.gradle I can't even start the client, it gives me this error message:

Execution failed for task ':runClient'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_241\bin\java.exe'' finished with non-zero exit value 1

For now I don't want this mod to do anything, I just want to see "4 mods loaded" when I run the client. What am I doing wrong (except trying to even do this without much experience)?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.