Jump to content

Config GUI


cad97

Recommended Posts

Is there an (easy) way to set one of your config settings as requiring a Minecraft restart? I see the way to set all to require a restart, but I don't see the place to set only one to that.

 

(I've set up the GUI thanks to the wonderful tutorial at http://minalien.com/minecraft-forge-feature-spotlight-config-guis/ and that part works fine.)

Link to comment
Share on other sites

You don't set it in the GuiConfig, instead you set it in your configuration itself.

 

At least by category, there are public methods in the Configuration class such as setCategoryRequiresWorldRestart() and setCategoryRequiresMcRestart(). 

 

Then by property, there are public methods in the Property class such as setRequiresWorldRestart() and setRequiresMcRestart().

 

So I think you can do all in GuiConfig, by category, or by property.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

I'm new to the forge configuration, so I'm kind of lost xD.

 

From what you said and what I can read this looks like it *should* be working:

 

public class ConfigurationHandler
{
    public static Configuration configuration;
    public static boolean spawnerCraftable;
    public static boolean spawnerDropRequireSilk;

    public static void init(File configFile)
    {
        // Create configuration object from given file
        if (configuration == null)
        {
            configuration = new Configuration(configFile);
            loadConfiguration();
        }
    }

    @SubscribeEvent
    public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event)
    {
        if (event.modID.equalsIgnoreCase(Reference.MOD_ID))
        {
            loadConfiguration();
        }
    }

    private static void loadConfiguration()
    {
        configuration.get("spawnerCraftable", Configuration.CATEGORY_GENERAL, false, "Whether you can craft an Empty spawner from iron bars").setRequiresMcRestart(true);
        spawnerCraftable = configuration.getBoolean("spawnerCraftable", Configuration.CATEGORY_GENERAL, false, "Whether you can craft an Empty spawner from iron bars");
        spawnerDropRequireSilk = configuration.getBoolean("spawnerDropRequireSilk", Configuration.CATEGORY_GENERAL, false, "Whether Empty Spawner drop requires Silk Touch");

        if (configuration.hasChanged())
        {
            configuration.save();
        }
    }
}

 

but the "Requires Minecraft Restart" flag isn't showing up for spawnerCraftable. The only thing that I can see that may be the cause is that the constructor for the GuiConfig overrides with the allRequireMinecraftRestart flag.

 

(Full repo code is at https://github.com/CAD97/SpawnerCraft)

Link to comment
Share on other sites

Aaaand I'm a derp.

 

configuration.get() takes the category then the field while configuration.getBoolean() takes the field and then the category. I switched them up and got weird results. It works though now!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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