Jump to content

How are you supposed to use GuiConfigEntries.SelectValueEntry?


Recommended Posts

Posted (edited)

I'm going to go insane. As with almost everything Forge there is basically no documentation to be found. I wanted to use the SelectValueEntry GUI entry in the same fashion I use numeric sliders - by telling Configuration Properties about this nice ConfigEntry class:

 

File configFile = event.getSuggestedConfigurationFile();
config = new Configuration(configFile);
config.get("Category", "Field", "Default").setConfigEntryClass(GuiConfigEntries.SelectValueEntry.class);

Naturally that doesn't work because the relevant constructor then doesn't know about SelectValueEntry's fourth required parameter that gives it the map with values.

I tried a bunch of different  things; mainly the least  ugly override of the class like so:

public class MySelectValueEntry extends GuiConfigEntries.SelectValueEntry {
	public MySelectValueEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) {
		super(owningScreen, owningEntryList, configElement,  ValueMap);
	}
}

where ValueMap is a previously constructed Map<Integer, String>, and just using it there instead. Seemed like a fairly okay solution, but I was met with an exception:

[01:59:12] [main/ERROR] [FML]: There was a critical error instantiating the custom IConfigEntry for config element cfg.field.
java.lang.NoSuchMethodException: net.amunak.minecraft.mod.Configuration$MySelectValueEntry.<init>(net.minecraftforge.fml.client.config.GuiConfig, net.minecraftforge.fml.client.config.GuiConfigEntries, net.minecraftforge.fml.client.config.IConfigElement)
	at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_181]
	at java.lang.Class.getConstructor(Class.java:1825) ~[?:1.8.0_181]
	at net.minecraftforge.fml.client.config.GuiConfigEntries.<init>(GuiConfigEntries.java:127) [GuiConfigEntries.class:?]
	at net.minecraftforge.fml.client.config.GuiConfig.<init>(GuiConfig.java:217) [GuiConfig.class:?]
	at net.minecraftforge.fml.client.config.GuiConfig.<init>(GuiConfig.java:153) [GuiConfig.class:?]
	at net.amunak.minecraft.mod.ModConfigGuiFactory$ConfigScreen$SimpleCategory.buildChildScreen(ModConfigGuiFactory.java:138) [ModConfigGuiFactory$ConfigScreen$SimpleCategory.class:?]
	at net.minecraftforge.fml.client.config.GuiConfigEntries$CategoryEntry.<init>(GuiConfigEntries.java:1322) [GuiConfigEntries$CategoryEntry.class:?]
	at net.amunak.minecraft.mod.ModConfigGuiFactory$ConfigScreen$SimpleCategory.<init>(ModConfigGuiFactory.java:121) [ModConfigGuiFactory$ConfigScreen$SimpleCategory.class:?]
	at net.amunak.minecraft.mod.ModConfigGuiFactory$ConfigScreen$EntitiesPlayersCategory.<init>(ModConfigGuiFactory.java:75) [ModConfigGuiFactory$ConfigScreen$EntitiesPlayersCategory.class:?]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_181]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [?:1.8.0_181]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [?:1.8.0_181]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) [?:1.8.0_181]
	at net.minecraftforge.fml.client.config.GuiConfigEntries.<init>(GuiConfigEntries.java:128) [GuiConfigEntries.class:?]
	at net.minecraftforge.fml.client.config.GuiConfig.initGui(GuiConfig.java:269) [GuiConfig.class:?]
	at net.minecraft.client.gui.GuiScreen.setWorldAndResolution(GuiScreen.java:543) [GuiScreen.class:?]
	at net.minecraft.client.Minecraft.displayGuiScreen(Minecraft.java:1097) [Minecraft.class:?]
	at net.minecraftforge.fml.client.GuiModList.actionPerformed(GuiModList.java:303) [GuiModList.class:?]
	at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:494) [GuiScreen.class:?]
	at net.minecraftforge.fml.client.GuiModList.mouseClicked(GuiModList.java:206) [GuiModList.class:?]
	at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:611) [GuiScreen.class:?]
	at net.minecraftforge.fml.client.GuiModList.handleMouseInput(GuiModList.java:352) [GuiModList.class:?]
	at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:576) [GuiScreen.class:?]
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:1885) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1187) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:441) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_181]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_181]
	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_181]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_181]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_181]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:25) [start/:?]

suggesting that a fitting  constructor(?) doesn't exist. You can look at the full and pretty much current source code for context. I specifically don't want to draw the menu "by hand" (thus bypassing the whole instantiation from net.minecraftforge.fml.client.config.GuiConfigEntries:126) to avoid duplicating tons of code that already works just fine inside Forge.

Did I miss something or am I doing it somehow completely wrong? I've been trying at it for the past like 4 hours without much recourse. Any ideas?

Edited by Amunak

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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