Jump to content

Recommended Posts

Posted

First post so excuse me if i don't include everything needed, but I find myself having a lot of trouble loading my config file into minecraft.  For some reason the config file is generated every time I delete it but when I go to my mod in minecraft the config button is greyed out. I'm working with 1.7.10, the error log says it can't initialize gui factory

 

 

 
[15:53:40] [Client thread/ERROR] [FML]: A critical error occurred instantiating the gui factory for mod betterRPG
java.lang.ClassCastException: class com.syntaxjedi.betterRPG.client.gui.BetterRPGguiConfig
at java.lang.Class.asSubclass(Unknown Source) ~[?:1.8.0_05]
at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:316) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:596) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:941) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_05]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_05]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_05]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_05]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?]

 

 

I've included a picture in case I'm not making myself clear enough.

 

 

AQnTsyG.png

 

 

Posted

The Button is grayed out for me as well... It seems like it is a WIP or you have to implement it yourself.

The error itself seems to be coming from your config class. Check if your config file is actually doing something (Being generated / accepting values), try to print out your config values and change them to see if they are actually being read.

But just an error (especially this) isn't enough to help you. Any code would be great :D

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Posted

I'm sort of following along with a tutorial and all my code matches that in the videos, the only difference is that in the videos the config button actually works.  I don't know which config class has the error, since I have two, so I'll post them both

 

 

configuration handler

 

 

package com.syntaxjedi.betterRPG.handler;

import java.io.File;
import com.syntaxjedi.betterRPG.reference.Reference;
import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.common.config.Configuration;

public class ConfigurationHandler 
{	
public static Configuration configuration;
public static boolean testValue = false;

public static void init(File configFile)
{	
	//create the configuration object from the given configuration file
	if (configuration == null)
	{	
		configuration = new Configuration(configFile);
		loadConfiguration();
	}
}

public static void loadConfiguration()
{
	testValue = configuration.getBoolean("configValue", Configuration.CATEGORY_GENERAL, false, "This is just a test value");

	if (configuration.hasChanged())
	{
		configuration.save();
	}
}

@SubscribeEvent
public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event)
{	
	if(event.modID.equalsIgnoreCase(Reference.MOD_ID))
	{
		loadConfiguration();			
	}
}
}

 

 

gui config

 

 

package com.syntaxjedi.betterRPG.client.gui;

import com.syntaxjedi.betterRPG.handler.ConfigurationHandler;
import com.syntaxjedi.betterRPG.reference.Reference;
import cpw.mods.fml.client.config.GuiConfig;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration;

public class BetterRPGguiConfig extends GuiConfig
{
public BetterRPGguiConfig(GuiScreen guiScreen)
{
	super (guiScreen,
			new ConfigElement(ConfigurationHandler.configuration.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(),
				Reference.MOD_ID,
				false,
				false,
				GuiConfig.getAbridgedConfigPath(ConfigurationHandler.configuration.toString()));
}
}

 

 

 

 

Posted

You have to actually load the Config file after creating it:

public static void loadConfiguration()
{
        configuration.load();
        ...

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Posted

I didn't know about the functionality of the Config buttons because I concentrated on other things recently since ID's aren't a problem anymore :/

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Posted

I tried loading the configuration in loadConfiguration(), which I'm sad I didn't do in the first place, but still nothing.  I'm about ready to say it's just not gonna work and give up  >:(

Posted

Where are you getting your config file path from? I got mine from "event.getSuggestedConfigurationFile()" in the MOD class.

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Posted

Where's your GUI factory class?  Can you show all your code related to configruation?  You should have an annotation in your main class pointing to the GUI factory class as well.  Also, you say you do it but don't show your proxy call to the init() where you pass the file location.  Coding is all about the details so need to see all related code to help you.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

class list

 

 

 

gui factory

 

package com.syntaxjedi.betterRPG.client.gui;

public class GuiFactory implements IModGuiFactory
{
@Override
public void initialize(Minecraft minecraftInstance) 
{

}

@Override
public Class<? extends GuiScreen> mainConfigGuiClass() 
{	
	return BetterRPGguiConfig.class;
}

@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() 
{	
	return null;
}

@Override
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) 
{	
	return null;
}

}

 

 

gui config

 

package com.syntaxjedi.betterRPG.client.gui;

public class BetterRPGguiConfig extends GuiConfig
{
public BetterRPGguiConfig(GuiScreen guiScreen)
{
	super (guiScreen,
			new ConfigElement(ConfigurationHandler.configuration.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(),
				Reference.MOD_ID,
				false,
				false,
				GuiConfig.getAbridgedConfigPath(ConfigurationHandler.configuration.toString()));
}
}

 

 

config handler

 

package com.syntaxjedi.betterRPG.handler;

public class ConfigurationHandler 
{	
public static Configuration configuration;
public static boolean testValue = false;

public static void init(File configFile)
{	
	//create the configuration object from the given configuration file
	if (configuration == null)
	{	
		configuration = new Configuration(configFile);
		loadConfiguration();
	}
}

public static void loadConfiguration()
{
	configuration.load();
	testValue = configuration.getBoolean("configValue", Configuration.CATEGORY_GENERAL, false, "This is just a test value");

	if (configuration.hasChanged())
	{
		configuration.save();
	}
}

@SubscribeEvent
public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event)
{	
	if(event.modID.equalsIgnoreCase(Reference.MOD_ID))
	{
		loadConfiguration();
	}
}
}

 

 

main mod class

 

package com.syntaxjedi.betterRPG;

@Mod(modid = Reference.MOD_ID, name= Reference.MOD_NAME, version= Reference.VERSION, guiFactory = Reference.CONFIG_GUI_CLASS)
public class betterRPG 
{	

@Mod.Instance(Reference.MOD_ID)
public static betterRPG instance;

@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
public static IProxy proxy;

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{		
	ConfigurationHandler.init(event.getSuggestedConfigurationFile());
	FMLCommonHandler.instance().bus().register(new ConfigurationHandler());
}

@Mod.EventHandler
public void init(FMLInitializationEvent event)
{

}

@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event)
{

}
}

 

 

also i get this message in the system output pane when i run the game and i don't know what exactly it's complaining about

[16:06:55] [Client thread/ERROR] [FML]: A critical error occurred instantiating the gui factory for mod betterRPG
java.lang.ClassCastException: class com.syntaxjedi.betterRPG.client.gui.BetterRPGguiConfig
at java.lang.Class.asSubclass(Unknown Source) ~[?:1.8.0_05]
at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:316) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:596) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:941) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_05]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_05]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_05]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_05]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?]

Posted

From the looks of your error, you aren't implementing an interface, or not extending something.

 

That's all I got for a ClassCastException.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Posted

That was my general thinking but I couldn't for the life of me figure out what to do, and google wasn't much help either :/

 

**EDIT**

I FIXED IT!!!! it was such a dumb mistake  >:( in my reference file i had

CONFIG_GUI_CLASS = "com.syntaxjedi.betterRPG.client.gui.BetterRPGguiConfig";

instead of

CONFIG_GUI_CLASS = "com.syntaxjedi.betterRPG.client.gui.GuiFactory";

:/

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.