use of net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent in project DynamicSurroundings by OreCruncher.
the class GuiConfigBase method actionPerformed.
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for
* buttons)
*/
@Override
protected void actionPerformed(GuiButton button) {
if (button.id == 2000) {
boolean flag = true;
try {
if ((this.configID != null || this.parentScreen == null || !(this.parentScreen instanceof GuiConfig)) && (this.entryList.hasChangedEntry(true))) {
final boolean requiresMcRestart = this.entryList.saveConfigElements();
// My hook for massaging the results
doFixups();
if (Loader.isModLoaded(this.modID)) {
final ConfigChangedEvent event = new OnConfigChangedEvent(this.modID, this.configID, this.isWorldRunning, requiresMcRestart);
MinecraftForge.EVENT_BUS.post(event);
if (!event.getResult().equals(Result.DENY))
MinecraftForge.EVENT_BUS.post(new PostConfigChangedEvent(this.modID, this.configID, this.isWorldRunning, requiresMcRestart));
if (requiresMcRestart) {
flag = false;
this.mc.displayGuiScreen(new GuiMessageDialog(this.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 (final Throwable e) {
FMLLog.log.error("Error performing GuiConfig action:", e);
}
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());
}
}
use of net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent 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());
}
}
Aggregations