Jump to content

Seeking Advanced Tutorial


ninjapancakes87

Recommended Posts

Hi all,

 

Let me just start off by saying I'd like to thank all of the helpful moderators and friendly people on this forum.  I essentially taught myself java by modding, and everybody here has been extremely helpful when I need help.  Now, I can apply what I've learned outside of modding, and It's come a long way.

 

But now I want to actually start doing more advanced things.  I've heard from another modder there is a way, using java.lang.reflect and ASM transformers to actually put methods into classes without base edits, or things of the sort.  Does anybody know of a page explaining ASM transformers and what I was talking about?  I have a basic idea of what reflect does.

 

Thanks in advance,

Ninjapancakes87

Link to comment
Share on other sites

Ok, first of all ASM and Reflection are two entirely different things.

Reflection allows you to access methods & fields you normally don't have access to (they are private for example).

ASM allows you to dynamically generate java bytecode from within your program. How that works? Well, when you compile your .java files, the java compiler produces .class files. What these contain is called bytecode, which is then executed by the actual JVM. This in-between step is what makes java reasonably fast, because the bytecode has a very limited instruction set and can therefor be executed very fast.

 

With ASM and the IClassTransformer interface (which is part of the official Mojang launcher btw, so this is theoretically independent from FML/Forge) you can now transform the bytecode of (almost) every class that get's loaded by the JVM. So I would first suggest a tutorial on the basics on bytecode (like this one: http://www.javaworld.com/article/2077233/core-java/bytecode-basics.html) and then learning ASM (for example here: http://www.javacodegeeks.com/2012/02/manipulating-java-class-files-with-asm.html).

 

Alright, I will check those out, thanks!

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.