Jump to content

Detecting installed mods


drinfernoo

Recommended Posts

Is there a way, with Forge, to detect which mods are installed? I'd like to try to make a mod that detects if the client has Optifine installed and decide based on that whether to use HD textures or not.

 

Something along the lines of:

//psuedocode
public String getTextureFile() {
   if (client has Optifine) {
      return "hdterrain.png";
   } else {
      return "terrain.png";
   }
}

Link to comment
Share on other sites

Well, first, Lex is gonna flip at the mention of optifine.

Why would I do that? Optifine is the good one, MCPatcher is the shit one.

But yes, FML detects optifine and sticks a fake mod container in there so people can detect it as a mod.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

So, am I looking in the wrong class/method?

 

I have this in my block class:

 

 

@Override
public String getTextureFile() {
    for (int i = 0; i < Loader.instance().getModList().size(); i++) {
        System.out.println(Loader.instance().getModList().get(i).getName());
    }

    if (Loader.isModLoaded("optifine")) {
        return "/com/drin/mods/gfx/hdterrain.png";
    } else {
        return "/com/drin/mods/gfx/terrain.png";
    }
}

 

 

 

And I am getting this stack trace:

 

 

2012-09-14 19:03:50 [iNFO] [ForgeModLoader] Forge Mod Loader version 3.0.196.366 for Minecraft client:1.3.2, server:1.3.2 loading
2012-09-14 19:03:52 [iNFO] [sTDOUT] 27 achievements
2012-09-14 19:03:52 [iNFO] [sTDOUT] 195 recipes
2012-09-14 19:03:52 [iNFO] [sTDOUT] Setting user: Player883, -
2012-09-14 19:03:52 [iNFO] [sTDERR] Client asked for parameter: server
2012-09-14 19:03:52 [iNFO] [sTDOUT] LWJGL Version: 2.4.2
2012-09-14 19:03:53 [iNFO] [ForgeModLoader] Attempting early MinecraftForge initialization
2012-09-14 19:03:53 [iNFO] [ForgeModLoader] Completed early MinecraftForge initialization
2012-09-14 19:03:53 [iNFO] [ForgeModLoader] Forge Mod Loader has detected optifine OptiFine_1.3.2_HD_U_B3, enabling compatibility features
2012-09-14 19:03:53 [iNFO] [ForgeModLoader] Searching H:\workspace\TutorialGui\jars\mods for mods
2012-09-14 19:03:53 [iNFO] [ForgeModLoader] Forge Mod Loader has identified 3 mods to load
2012-09-14 19:03:54 [iNFO] [sTDOUT] Forge Mod Loader
2012-09-14 19:03:54 [iNFO] [sTDOUT] Minecraft Forge
2012-09-14 19:03:54 [iNFO] [sTDOUT] EnigmaCraft
2012-09-14 19:03:54 [iNFO] [sTDOUT] Forge Mod Loader
2012-09-14 19:03:54 [iNFO] [sTDOUT] Minecraft Forge
2012-09-14 19:03:54 [iNFO] [sTDOUT] EnigmaCraft
2012-09-14 19:03:54 [iNFO] [sTDOUT] Starting up SoundSystem...
2012-09-14 19:03:54 [iNFO] [sTDOUT] Initializing LWJGL OpenAL
2012-09-14 19:03:54 [iNFO] [sTDOUT]     (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
2012-09-14 19:03:54 [iNFO] [sTDOUT] OpenAL initialized.
2012-09-14 19:03:55 [iNFO] [ForgeModLoader] Forge Mod Loader has successfully loaded 3 mods

 

 

 

But I know I have Optifine installed (and working), as shown here:

 

 

qBpdL.png

 

 

 

And yes, I know I'm a few builds behind on Forge :P

 

What am I doing wrong?

Link to comment
Share on other sites

Well, first, Lex is gonna flip at the mention of optifine.

Why would I do that? Optifine is the good one, MCPatcher is the shit one.

But yes, FML detects optifine and sticks a fake mod container in there so people can detect it as a mod.

Oh.

I get the two mixed up sometimes, and I wans't really awake...

Anyway, that's a pretty easy way to detect mods.

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

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.



×
×
  • Create New...

Important Information

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