Jump to content

Autogenerating Classes [SOLVED]


Recommended Posts

Hello there,

I am trying to something a little unconventional... I hope I am right here and this is an allowed question.

Basically, I'm working on a sort of wrapper on top of forge - allowing mods for older version to work. The specifics of that shouldn't matter, but I'm looking to improve the way I go about things.
To do the heavy lifting, I'm using wrappers - I've spent quite some time on the architecture, and I don't think that's avoidable. However, a lot of the code is redundant and I want to autogenerate it.

Let's take the following (pseudocode) example:

public interface IBlockWrapper
	public void setXYZ();

I want to generate an implementation for that interface:

public class BlockWrapper implements IBlockWrapper
	private Block block;

	public BlockWrapper(Block block)
		this.block = block;

	public void setXYZ()
		// ...


Currently I generate the classes for the interfaces at runtime using asm and then loading them into the running program. Which is a pretty... terrible approach, actually.

What I'm looking for is a way to generate an actual .java class, that
a) works in eclipse and
b) will be compiled into the finished jar (and properly re-obfuscated to srg)

I searched around, and apparently there are Annotation Processors that seem suited, but I am not entirely sure.
Could you help point me in the right direction on how to approach that problem? Surely I'm not the first who wants to autogenerate classes.
I understand that what I'm doing might sound crazy, but I'd prefer if this doesn't turn into a discussion on why what I'm doing is a bad idea. I just like hacking Minecraft, what should I say.


EDIT: For the setup, I want it to work with a clean 1.16.5 forge install (latest version). Using the gradle version and eclipse-generating capabilities that comes with. Once that works, I'll integrate it into my existing code base, and might try to backport it on my own. But the final target should still be 1.16.X.




Edited by DarkShadow44
Link to comment
Share on other sites

  • DarkShadow44 changed the title to Autogenerating Classes [SOLVED]

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.

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.

  • Create New...

Important Information

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