Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

What are the basic ways of creating/readingfrom/writing to config files? I have searched for the forge config api on the docs but all links on google take you to the readthedocs homepage...

 

If anyone could tell me, or link me a working example (as the docs are screwed) of how to:

Create a base config file if one doesn't exist

Write to a config file

Read from a config file

 

Thanks for anyone willing to help :)

I'd look at:

net.minecraftforge.common.config.Configuration

...

 

 

Here is a class from an older mod I have:

public class Config {

    public static Configuration config;

    public static void preInit() {
        config = new Configuration(new File(Reference.MAIN_FOLDER + "/Enabled_Modules.cfg"));

        try{
            config.load();

            // module on/off states \\
            RingsHUD.Enabled = config.getBoolean("CheckpointHUD","Modules",true,"Whether to show the CheckpointHUD.");
            RingsHUD.DisableChat = config.getBoolean("DisableCPChat","Modules",true,"Whether to disable the checkpoint reached message in chat.");
            TIPCanceler.Enabled = config.getBoolean("ShowTips","Modules",true,"Whether to show Tips.");
            TimerGuiClass.Enabled = config.getBoolean("ShowTimer","Modules",true,"Whether to show the Timer.");


        }catch(Exception e){
            System.out.println("Error loading config, returning to default variables.");
        }finally {
            config.save();
        }
    }

    public static void setModule(String module, boolean to){
        config.get("Modules",module,true).set(to);
        config.save();
        preInit();
    }
}

Ofc the preInit is called from the mod's preInit,

But you can call it anytime I'm pretty sure to update it...

Its my code so if something dont work dont blame me cuz im stupid :D

 

I used the

setModule(String module, boolean to)

to set the module's state ingame, a.k.a in an options gui...

Doing stuff n' things

Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.