Jump to content

Poipt

Members
  • Posts

    3
  • Joined

  • Last visited

Poipt's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hi, I am trying to write to a config file in MC 1.8.9. I type in the new value (90, previously 45), press done, and I go back in the config, and it's 45 again! Code to write to value: public static void syncConfig() { try { config.load(); Property configFOV = config.get(Configuration.CATEGORY_GENERAL, "FOV", "45", "Amount to zoom to"); FOVVal = configFOV.getInt(); System.out.println(FOVVal); } catch (Exception error) { } finally { config.save(); } } Code for detecting if done button is pushed: protected void actionPerformed(GuiButton button) { if (button.id == 2000) { FOVMod.syncConfig(); boolean flag = true; try { if ((configID != null || parentScreen == null || !(parentScreen instanceof FOVGuiConfig)) && (entryList.hasChangedEntry(true))) { boolean requiresMcRestart = entryList.saveConfigElements(); if (Loader.isModLoaded(Reference.MODID)) { ConfigChangedEvent event = new OnConfigChangedEvent(Reference.MODID, "FOV", isWorldRunning, false); MinecraftForge.EVENT_BUS.post(event); if (!event.getResult().equals(Result.DENY)) MinecraftForge.EVENT_BUS.post(new PostConfigChangedEvent(Reference.MODID, "FOV", isWorldRunning, false)); if (requiresMcRestart) { flag = false; mc.displayGuiScreen(new GuiMessageDialog(parentScreen, "fml.configgui.gameRestartTitle", new ChatComponentText(I18n.format("fml.configgui.gameRestartRequired")), "fml.configgui.confirmRestartMessage")); } if (parentScreen instanceof FOVGuiConfig) ((FOVGuiConfig) parentScreen).needsRefresh = true; } } } catch (Throwable e) { e.printStackTrace(); } if (flag) mc.displayGuiScreen(parentScreen); } } I have been working on this for hours, and any help would be appreciated greatly. Thanks!
  2. OK, I crosschecked my code with some examples, and there were a few things missing. I added those things, but I am still getting the same error. EDIT: I fixed it! The problem was that I didn't have a config file set up.
  3. Hi, I'm trying to create a mod for Minecraft 1.8.9 that allows you to zoom in with a keypress. For my GuiFactory, I am having a number input that allows you to customize the amount to zoom in by. So far, I have followed Jabelar's tutorial about GuiFactories, but whenever I open the config for my mod, I get this error: [12:36:22] [Client thread/ERROR] [FML]: There was a critical issue trying to build the config GUI for fovmod java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_91] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_91] at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_91] at net.minecraftforge.fml.client.GuiModList.actionPerformed(GuiModList.java:293) [GuiModList.class:?] at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:509) [GuiScreen.class:?] at net.minecraftforge.fml.client.GuiModList.mouseClicked(GuiModList.java:197) [GuiModList.class:?] at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:621) [GuiScreen.class:?] at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:587) [GuiScreen.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1761) [Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1080) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:380) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:116) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_91] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_91] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] Caused by: java.lang.NullPointerException at fovmod.gui.FOVGuiConfig.<init>(FOVGuiConfig.java:26) ~[FOVGuiConfig.class:?] ... 25 more Here is my GuiFactory code: package fovmod.gui; import java.util.HashSet; import java.util.Set; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.fml.client.IModGuiFactory; public class FOVGuiFactory implements IModGuiFactory { @Override public void initialize(Minecraft minecraftInstance) { } @Override public Class<? extends GuiScreen> mainConfigGuiClass() { return FOVGuiConfig.class; } @Override public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() { return null; } @Override public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { return null; } } And here is my config code (I do not have a tutorial for my number input yet, so if you could also point me in the direction of a tutorial to do that, that would be great): package fovmod.gui; import fovmod.FOVMod; import fovmod.Reference; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.resources.I18n; import net.minecraft.util.ChatComponentText; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.ConfigElement; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.client.config.GuiMessageDialog; import net.minecraftforge.fml.client.event.ConfigChangedEvent; import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; import net.minecraftforge.fml.client.event.ConfigChangedEvent.PostConfigChangedEvent; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.eventhandler.Event.Result; import net.minecraftforge.fml.client.IModGuiFactory; public class FOVGuiConfig extends net.minecraftforge.fml.client.config.GuiConfig { public FOVGuiConfig(GuiScreen parentScreen) { super(parentScreen, new ConfigElement(Reference.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), Reference.MODID, false, false, "test"); } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { title = "test"; super.drawScreen(mouseX, mouseY, partialTicks); } @Override protected void actionPerformed(GuiButton button) { if (button.id == 2000) { System.out.println("Pressed DONE button"); boolean flag = true; try { if ((configID != null || parentScreen == null || !(parentScreen instanceof FOVGuiConfig)) && (entryList.hasChangedEntry(true))) { System.out.println("Saving config elements"); boolean requiresMcRestart = 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 ChatComponentText(I18n.format("fml.configgui.gameRestartRequired")), "fml.configgui.confirmRestartMessage")); } if (parentScreen instanceof FOVGuiConfig) ((FOVGuiConfig) parentScreen).needsRefresh = true; } } } catch (Throwable e) { e.printStackTrace(); } if (flag) mc.displayGuiScreen(parentScreen); } } } Thank you so much! If you have any questions, let me know.
×
×
  • Create New...

Important Information

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