Jump to content

Configuration GUI (Version 1.8.x)


MiSt Rocky

Recommended Posts

So I have recently been working on a 1.8.9 forge mod, just to play around and see what there is (eventually I am planning on making a utilities mod with versions for 1.8-1.19, which is why I'm so far back).  I have had no problems... until I got to configs.  I already have code to create and read from a config file, but I can not figure out how to use Forge's mod options > config menu to allow GUI modification of the settings.  I have had no luck finding any information on how to do this back in 1.8, so if anyone could help me out a bit (linking sources, giving example code, or referring me to a forge class that has the relevant code in it), I would greatly appreciate it.  

My current config code (in the Main class):

    public static Configuration config;
    private File confDir;
	
	public static Logger lmao;

	public static Configuration getConfig()
    {
        return config;
    }
    @EventHandler
    public void preinit(FMLPreInitializationEvent event) {
        lmao = event.getModLog();

        confDir = event.getModConfigurationDirectory();
        config = null;
        File configFile = new File(confDir,"config.cfg");
        config = new Configuration(configFile);
        syncConfig(true);
        event.getModLog().log(Level.ALL,"Preinitialization complete.");
	}
	private static void syncConfig(boolean load)
    {
        List<String> propOrder = new ArrayList<String>();

        if (!config.isChild)
        {
            if (load)
            {
                config.load();
            }
            Property enableGlobalCfg = config.get(CATEGORY_GENERAL, "enableGlobalConfig", false).setShowInGui(false);
            if (enableGlobalCfg.getBoolean(false))
            {
                Configuration.enableGlobalConfig();
            }
        }

        Property prop;

        //set prop value, then:
        //propOrder.add(prop.getName());

        prop = config.get(CATEGORY_GENERAL,"testbool",false);
        prop.comment = "for testing purposes";
        prop.setLanguageKey("mod.conf.testbool");
        propOrder.add(prop.getName());

        prop = reConf.get(CATEGORY_GENERAL,"testvar","can you see this?");
        prop.comment = "for testing purposes only";
        prop.setLanguageKey("mod.conf.teststring");
        propOrder.add(prop.getName());

        config.setCategoryPropertyOrder(CATEGORY_GENERAL, propOrder);


        if (config.hasChanged())
        {
            config.save();
        }
    }
          public static void syncConf(boolean load1) {
          //public configuration sync method
        syncConfig(load1);
    }
    @SubscribeEvent
    public void onConfigChangedEvent(OnConfigChangedEvent event)
    {
        if (event.modID.equals(MODID))
        {
            if (Configuration.CATEGORY_GENERAL.equals(event.configID))
            {
                syncConfig(false);
            }
        }
    }
          //much of this was taken from or inspired by forge's source code, and adapted to work with this mod.

 

If anyone can help, please do.  If this post is breaking a forum rule, DEFINITELY tell me, since I need to know.

Thanks ahead of time,  

-MiSt_Rocky

Link to comment
Share on other sites

Why don't you try contacting the people that are still updating modpacks for 1.8 on curseforge?

https://www.curseforge.com/minecraft/search?page=1&class=modpacks&gameVersion=1.8&sortType=3&pageSize=20

Looking at that list, the latest update that actually was for 1.8 was September last year.

So I wouldn't hold out much hope in finding an active community for that version.

 

Maybe try 1.7 which still has the GTNH modpack developers updating and fixing mods? Or 1.12 has a similar group.

Edited by warjort
  • Like 1

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

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