Posted July 10, 20178 yr This snippet of code came from a 1.11 mod I'm trying to use to create a gui config. I think maybe the code was changed between 1.11 and 1.12 as it's telling me it can't me resolved. package com.fuzzybat23.csbr.config; import java.util.Set; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.fml.client.IModGuiFactory; public class GuiFactory implements IModGuiFactory { @Override public void initialize(Minecraft minecraftInstance) { } @Override <---- Error 1 public Class<? extends GuiScreen> mainConfigGuiClass() { return GuiModConfig.class; } @Override <---- Error 2 public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() <---- Error 3 { return null; } @Override public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { return null; } @Override public boolean hasConfigGui() { return true; } @Override public GuiScreen createConfigGui(GuiScreen parentScreen) { return new GuiModConfig(parentScreen); } } Error 1 and Error 2 say "Method does not override method from its superclass." Error 3 is in reference to RuntimeOptionGuiHandler and says "Cannot resolve symbol 'RuntimeOptionGuiHandler' Any one know if this has been changed? This GuiFactory is a direct copy of another person's code that does compile, as far as I know, as his mod has been released with no errors. mainConfigGuiClasss refers to net.minecraftforge.fml.client.config.GuiConfig.java which reads: public GuiConfig(GuiScreen parentScreen, String modID, boolean allRequireWorldRestart, boolean allRequireMcRestart, String title, Class<?>... configClasses) { this(parentScreen, collectConfigElements(configClasses), modID, null, allRequireWorldRestart, allRequireMcRestart, title, null); } and the new GuiModConfig.java in my mod directory reads: package com.fuzzybat23.csbr.config; import com.fuzzybat23.csbr.CSBR; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigElement; import net.minecraftforge.fml.client.config.GuiConfig; public class GuiModConfig extends GuiConfig { public GuiModConfig(GuiScreen parent) { super( parent, new ConfigElement(CSBR.instance.config.file.getCategory("general")).getChildElements(), CSBR.MODID, false, false, GuiConfig.getAbridgedConfigPath(CSBR.instance.config.file.toString()) ); } }
July 10, 20178 yr 10 minutes ago, fuzzybat23 said: Error 1 and Error 2 say "Method does not override method from its superclass." Those particular methods have been deleted as they've been deprecated for a while now. 11 minutes ago, fuzzybat23 said: Error 3 is in reference to RuntimeOptionGuiHandler and says "Cannot resolve symbol 'RuntimeOptionGuiHandler' RuntimeOptionGuiHandler was deleted as, quoting the javadocs for RuntimeOptionGuiHandler from 1.11 code: TODO remove in 1.11 - this was never fully implemented and will be removed And it also was deprecated btw.
July 10, 20178 yr Author Actually, mainConfigGuiClass wasn't deleted, it was renamed. It's still in IModGuiFactory, but as createConfigGui. The old -> public Class<? extends GuiScreen> mainConfigGuiClass(); /** * Return a list of the "runtime" categories this mod wishes to populate with * GUI elements. * * Runtime categories are created on demand and organized in a 'lite' tree format. * The parent represents the parent node in the tree. There is one special parent * 'Help' that will always list first, and is generally meant to provide Help type * content for mods. The remaining parents will sort alphabetically, though * this may change if there is a lot of alphabetic abuse. "AAA" is probably never a valid * category parent. * * Runtime configuration itself falls into two flavours: in-game help, which is * generally non interactive except for the text it wishes to show, and client-only * affecting behaviours. This would include things like toggling minimaps, or cheat modes * or anything NOT affecting the behaviour of the server. Please don't abuse this to * change the state of the server in any way, this is intended to behave identically * when the server is local or remote. * * @return the set of options this mod wishes to have available, or empty if none */ The New -> public GuiScreen createConfigGui(GuiScreen parentScreen); /** * Return a list of the "runtime" categories this mod wishes to populate with * GUI elements. * * Runtime categories are created on demand and organized in a 'lite' tree format. * The parent represents the parent node in the tree. There is one special parent * 'Help' that will always list first, and is generally meant to provide Help type * content for mods. The remaining parents will sort alphabetically, though * this may change if there is a lot of alphabetic abuse. "AAA" is probably never a valid * category parent. * * Runtime configuration itself falls into two flavours: in-game help, which is * generally non interactive except for the text it wishes to show, and client-only * affecting behaviours. This would include things like toggling minimaps, or cheat modes * or anything NOT affecting the behaviour of the server. Please don't abuse this to * change the state of the server in any way, this is intended to behave identically * when the server is local or remote. * * @return the set of options this mod wishes to have available, or empty if none */ So get rid of the runtime handler completely, eh? Well, as for the other one which was renamed, not deleted, I redid the code as: @Override public Class<? extends GuiScreen> createConfigGui() { return ConfigGui.class; } It throws the same error though. Should I just erase that line, as well, and delete the GuiModConfig.java file and add it directly into the GuiFactory? package com.fuzzybat23.csbr.config; import java.util.Set; import com.fuzzybat23.csbr.CSBR; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigElement; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.client.IModGuiFactory; import net.minecraftforge.fml.client.config.GuiConfig; public class GuiFactory implements IModGuiFactory { @Override public void initialize(Minecraft minecraftInstance) { } // @Override // public Class<? extends GuiScreen> createConfigGui() // { // return ConfigGui.class; // } @Override public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() { return null; } @Override public boolean hasConfigGui() { return true; } @Override public GuiScreen createConfigGui(GuiScreen parentScreen) { return new ConfigGui(parentScreen); } public static class ConfigGui extends GuiConfig { public ConfigGui(GuiScreen parent) { super(parent, new ConfigElement(CSBR.instance.config.file.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), CSBR.MODID, false, false, GuiConfig.getAbridgedConfigPath(CSBR.instance.config.file.toString())); } } }
July 10, 20178 yr 7 minutes ago, fuzzybat23 said: Actually, mainConfigGuiClass wasn't deleted, it was renamed. It's still in IModGuiFactory, but as createConfigGui. No it was deleted, look at the signatures: 1.11: public Class<? extends GuiScreen> mainConfigGuiClass(); 1.12 public GuiScreen createConfigGui(GuiScreen parentScreen); How is that renamed? The return type changed, a parameter had been introduced and the name is different. This does not look like a rename to me. Especially considering the fact that 1.11 has the createConfigGui method with the exact 1.12 signature. 9 minutes ago, fuzzybat23 said: It throws the same error though. Yes it does. There is no public Class<? extends GuiScreen> createConfigGui() method for you to override or implement in the interface. Your last code attachment looks fine to me.
July 10, 20178 yr Author Well, it compiles just fine. I ran the other mod that has the original code and it's config screen opens just fine. Mine doesn't crash when I click on the Config button,but it does throw this: [19:35:13] [main/ERROR] [FML]: There was a critical issue trying to build the config GUI for csbr java.lang.NullPointerException: null at com.fuzzybat23.csbr.config.GuiFactory$ConfigGui.<init>(GuiFactory.java:47) ~[GuiFactory$ConfigGui.class:?] at com.fuzzybat23.csbr.config.GuiFactory.createConfigGui(GuiFactory.java:40) ~[GuiFactory.class:?] at net.minecraftforge.fml.client.GuiModList.actionPerformed(GuiModList.java:301) [GuiModList.class:?] at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:494) [GuiScreen.class:?] at net.minecraftforge.fml.client.GuiModList.mouseClicked(GuiModList.java:205) [GuiModList.class:?] at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:611) [GuiScreen.class:?] at net.minecraftforge.fml.client.GuiModList.handleMouseInput(GuiModList.java:351) [GuiModList.class:?] at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:576) [GuiScreen.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1861) [Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1171) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:436) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131] 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_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?]
July 10, 20178 yr 3 minutes ago, fuzzybat23 said: java.lang.NullPointerException: null at com.fuzzybat23.csbr.config.GuiFactory$ConfigGui.<init>(GuiFactory.java:47) ~[GuiFactory$ConfigGui.class:?] Well, something in your ConfigGui constructor is null. Try setup a breakpoint to figure out what. The potential culprits are: 19 minutes ago, fuzzybat23 said: CSBR.instance 19 minutes ago, fuzzybat23 said: CSBR.instance.config 19 minutes ago, fuzzybat23 said: CSBR.instance.config.file
July 11, 20178 yr Author My main class is: package com.fuzzybat23.csbr; import com.fuzzybat23.csbr.config.ConfigManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.io.File; @net.minecraftforge.fml.common.Mod(modid = "csbr", version = "1.0", clientSideOnly = true, acceptedMinecraftVersions = "[1.12, 1.13)", guiFactory = "com.fuzzybat23.csbr.config.GuiFactory") public class CSBR { @net.minecraftforge.fml.common.Mod.Instance("CSBR") public static final String MODID = "csbr"; public static CSBR instance; public ConfigManager config; public CSBR() { } @Mod.EventHandler @SideOnly(Side.CLIENT) public void preInit(FMLPreInitializationEvent event) { config = new ConfigManager(event.getModConfigurationDirectory()); } @Mod.EventHandler @SideOnly(Side.CLIENT) public void initialize(FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(config); } @Mod.EventHandler @SideOnly(Side.CLIENT) public void load(FMLInitializationEvent event) { } } I can't figure out where that null is coming from
July 11, 20178 yr 9 hours ago, fuzzybat23 said: public static CSBR instance; This field is null and you never assign anything to it. 9 hours ago, fuzzybat23 said: @net.minecraftforge.fml.common.Mod.Instance("CSBR") public static final String MODID = "csbr"; An Instance annotation goes over a field you want an instance of your mod to be injected into, not over the field that contains your modid.
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.