Jump to content

How to get file path to mod file?


planetguy

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...