Jump to content

How to use AccessTransformer in Forge 10.x


lin7889

Recommended Posts

I had already read this tutorial about access transformer(http://www.minecraftforge.net/wiki/Using_Access_Transformers), it only told me how to change modifiers of fields or methods by using  "*_at.cfg" , not using a Class which extends from AccessTransformer .

 

Previously, the file "META-INF\MANIFEST.MF" can help forge to find the transformer class. But now, it didn't work. The codes in transformer class has never been run.

I'm really confused. I'm hoping someone can help me to figure it out. thanks

Link to comment
Share on other sites

The manifest should point to your IFMLLoadingPlugin implementation.

This interface changed recently with a new direct getter for the access transformer class.

Given the way AccessTransformer is written, it is meant to point at the file passed through its constructor. Thus you only need to do that.

IClassTransformer implementations are still loaded the same as before.

Link to comment
Share on other sites

I'm now running atomicstryker's simplyhax source code for transformer testing in IntelliJ with minecraft 1.7.2 workspace.

I think I do the right things.

 

Here is the MANIFEST.MF

 

Manifest-Version: 1.0

Ant-Version: Apache Ant 1.8.4

Created-By: 1.7.0 (Oracle Corporation)

FMLCorePlugin: atomicstryker.simplyhax.SHFMLCorePlugin

 

 

 

 

And SHFMLCorePlugin.java

 

package atomicstryker.simplyhax;

 

import java.util.Map;

 

import cpw.mods.fml.relauncher.IFMLLoadingPlugin;

 

public class SHFMLCorePlugin implements IFMLLoadingPlugin

{

 

    @Override

    public String[] getASMTransformerClass()

    {

        return new String[] { "atomicstryker.simplyhax.SHTransformer" };

    }

 

    @Override

    public String getModContainerClass()

    {

        return null;

    }

 

    @Override

    public String getSetupClass()

    {

        return null;

    }

 

    @Override

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

    {

    }

 

    @Override

    public String getAccessTransformerClass()

    {

        return null;

    }

 

}

 

 

 

 

 

SHTransformer.java

 

public class SHTransformer implements IClassTransformer

{

    /* class net.minecraft.src.EntityPlayerSP */

    private final String classNamePlayerObfusc = "bex";

   

    private final String classNamePlayer = "net.minecraft.client.entity.EntityPlayerSP";

   

    @Override

    public byte[] transform(String name, String newName, byte[] bytes)

    {

        System.out.println("transforming: "+name);  // I saw nothing about transforming in output window.

        if (name.equals(classNamePlayerObfusc))

        {

            return handleTransform(bytes, true);

        }

        else if (name.equals(classNamePlayer))

        {

            return handleTransform(bytes, false);

        }

       

        return bytes;

    }

   

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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