Jump to content

How to get file path to mod file?


planetguy
 Share

Recommended Posts

Some background:

Since my mod, Gizmos, can be horribly destructive to servers but also quite useful, I wanted to make a system whereby any component can be turned off as desired by admins. At first I set up a "loader node" class for each component of the mod, but that system requires so much boilerplate that some times, I just don't want to bother adding a feature because of it.

Recently I decided that the present system has to go. To make a new system, I figured I'd make something based on annotations: plop a @GizmosModule("name") onto a block/item/tile entity class and it will automatically create the necessary config properties for its ID and register the thing, if it's not on the ban list. The issue is that Java doesn't have an easy way to get all the loaded classes, so I have to use the filesystem API to find my classes.

So far I've tried stealing a reference to the file from ForgeModLoader, but it isn't allowed to reflect over those classes. Ideas anyone?

Link to comment
Share on other sites

  • 2 months later...

Update: Minecraft.getMinecraft().getMinecraftDir() works beautifully on the client. Just today, I tried running the same code on a server and it crashes, since Minecraft.class is apparently client-side-only. I tried using the path from MinecraftServer, but it seems to not be fully initialized at load time. Any other ideas?

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

 Share

×
×
  • Create New...