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

When I set my config option to true in the Config GUI, it doesn't save the change. I set up a System.out.println("[ModCompat] Code Activated"); in the onConfigChanged code, as shown below, and it doesn't activate after setting the config in the Config GUI.

 

@Mod(modid = "modcompat", name="Mod Compatibility Patch", version="1.0.0", acceptedMinecraftVersions = "1.7.2,1.7.10", guiFactory = "the_fireplace.modcompat.config.ModCompatGuiFactory")
public class ModCompatBase {
@Instance(value = "modcompat")
        public static ModCompatBase instance;
public static Configuration config;
        public static Property FIRSTTIME_PROPERTY;

public static void syncConfig() {
FIRSTTIME_PROPERTY = config.get(Configuration.CATEGORY_GENERAL, ModCompatConfigValues.FIRSTTIME_NAME, ModCompatConfigValues.FIRSTTIME_DEFAULT);
ModCompatConfigValues.FIRSTTIME = FIRSTTIME_PROPERTY.getBoolean();
// get other properties here
if(ModCompatConfigValues.FIRSTTIME) {
	System.out.println("[ModCompat]Doing one-time scan...");
	FIRSTTIME_PROPERTY.set(false);
}
if (config.hasChanged()) {
                config.save();
}
}
@EventHandler
public void PreInit(FMLPreInitializationEvent event){
//Config code
config = new Configuration(event.getSuggestedConfigurationFile());
        config.load();
syncConfig();
}

@SubscribeEvent
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) {
System.out.println("[ModCompat] Code Activated");
     if(eventArgs.modID.equals("modcompat")){
        syncConfig();
        }
}
}

 

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

  • Author

You need to register your EventHandler to the EventBus.

Ok, I've done that, and it still does the same thing. Here is the new code:

Main Class:

 

@Mod(modid = "modcompat", name="Mod Compatibility Patch", version="1.0.0", acceptedMinecraftVersions = "1.7.2,1.7.10", guiFactory = "the_fireplace.modcompat.config.ModCompatGuiFactory")
public class ModCompatBase {
@Instance(value = "modcompat")
        public static ModCompatBase instance;
public static Configuration config;
        public static Property FIRSTTIME_PROPERTY;

public static void syncConfig() {
FIRSTTIME_PROPERTY = config.get(Configuration.CATEGORY_GENERAL, ModCompatConfigValues.FIRSTTIME_NAME, ModCompatConfigValues.FIRSTTIME_DEFAULT);
ModCompatConfigValues.FIRSTTIME = FIRSTTIME_PROPERTY.getBoolean();
// get other properties here
if(ModCompatConfigValues.FIRSTTIME) {
	System.out.println("[ModCompat]Doing one-time scan...");
	FIRSTTIME_PROPERTY.set(false);
}
if (config.hasChanged()) {
                config.save();
}
}
@EventHandler
public void PreInit(FMLPreInitializationEvent event){
//Config code
config = new Configuration(event.getSuggestedConfigurationFile());
        config.load();
syncConfig();
}
@EventHandler
public void Init(FMLInitializationEvent event){
MinecraftForge.EVENT_BUS.register(new ConfigChangedHandler());
}
}

 

And the ConfigChangedHandler:

 

public class ConfigChangedHandler {
@SubscribeEvent
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) {
   	 System.out.println("[ModCompat]Config Changed");
     if(eventArgs.modID.equals("modcompat")){
        ModCompatBase.syncConfig();
      	 System.out.println("[ModCompat]ModCompat Config Changed");
     }
}
}

 

EDIT: Another piece of possibly important information: My config is in a subcategory of the main GUI Config, like the way the Minecraft Forge config GUI is set up.

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

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.