Search in sources :

Example 1 with PostConfigChangedEvent

use of net.minecraftforge.fml.client.event.ConfigChangedEvent.PostConfigChangedEvent in project MinecraftForge by MinecraftForge.

the class GuiConfig method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    if (button.id == 2000) {
        boolean flag = true;
        try {
            if ((configID != null || this.parentScreen == null || !(this.parentScreen instanceof GuiConfig)) && (this.entryList.hasChangedEntry(true))) {
                boolean requiresMcRestart = this.entryList.saveConfigElements();
                if (Loader.isModLoaded(modID)) {
                    ConfigChangedEvent event = new OnConfigChangedEvent(modID, configID, isWorldRunning, requiresMcRestart);
                    MinecraftForge.EVENT_BUS.post(event);
                    if (!event.getResult().equals(Result.DENY))
                        MinecraftForge.EVENT_BUS.post(new PostConfigChangedEvent(modID, configID, isWorldRunning, requiresMcRestart));
                    if (requiresMcRestart) {
                        flag = false;
                        mc.displayGuiScreen(new GuiMessageDialog(parentScreen, "fml.configgui.gameRestartTitle", new TextComponentString(I18n.format("fml.configgui.gameRestartRequired")), "fml.configgui.confirmRestartMessage"));
                    }
                    if (this.parentScreen instanceof GuiConfig)
                        ((GuiConfig) this.parentScreen).needsRefresh = true;
                }
            }
        } catch (Throwable e) {
            e.printStackTrace();
        }
        if (flag)
            this.mc.displayGuiScreen(this.parentScreen);
    } else if (button.id == 2001) {
        this.entryList.setAllToDefault(this.chkApplyGlobally.isChecked());
    } else if (button.id == 2002) {
        this.entryList.undoAllChanges(this.chkApplyGlobally.isChecked());
    }
}
Also used : PostConfigChangedEvent(net.minecraftforge.fml.client.event.ConfigChangedEvent.PostConfigChangedEvent) OnConfigChangedEvent(net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent) ConfigChangedEvent(net.minecraftforge.fml.client.event.ConfigChangedEvent) PostConfigChangedEvent(net.minecraftforge.fml.client.event.ConfigChangedEvent.PostConfigChangedEvent) OnConfigChangedEvent(net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

TextComponentString (net.minecraft.util.text.TextComponentString)1 ConfigChangedEvent (net.minecraftforge.fml.client.event.ConfigChangedEvent)1 OnConfigChangedEvent (net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent)1 PostConfigChangedEvent (net.minecraftforge.fml.client.event.ConfigChangedEvent.PostConfigChangedEvent)1