Posted April 22, 20187 yr 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. Edited April 22, 20187 yr by Poipt
April 22, 20187 yr 53 minutes ago, Poipt said: @Override public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() { return null; } @Override public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { return null; } This does not seem correct to me. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
April 22, 20187 yr Author 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. Edited April 22, 20187 yr by Poipt
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.