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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • that happens every time I enter a new dimension.
    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
  • Topics

×
×
  • Create New...

Important Information

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