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.