Jump to content

Gui Config


tattyseal

Recommended Posts

Hello!

 

I added GUI Configs, but when I try to open it I get this error

 

 

java.lang.NoSuchMethodException: com.tattyseal.zaet.configuration.ZaetConfigGUI.<init>(net.minecraft.client.gui.GuiScreen)

at java.lang.Class.getConstructor0(Class.java:2810) ~[?:1.7.0_45]

at java.lang.Class.getConstructor(Class.java:1718) ~[?:1.7.0_45]

at cpw.mods.fml.client.GuiModList.actionPerformed(GuiModList.java:124) [GuiModList.class:?]

at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:254) [GuiScreen.class:?]

at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:346) [GuiScreen.class:?]

at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:315) [GuiScreen.class:?]

at net.minecraft.client.Minecraft.runTick(Minecraft.java:1730) [Minecraft.class:?]

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1038) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:961) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_45]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_45]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_45]

at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_45]

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:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_45]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_45]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_45]

at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_45]

at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) [idea_rt.jar:?]

 

 

 

Main Mod File

 

 

package com.tattyseal.zaet;

 

import com.tattyseal.zaet.api.ZaetItem;

import com.tattyseal.zaet.configuration.Config;

import com.tattyseal.zaet.event.ZaetHandler;

import com.tattyseal.zaet.item.ItemPineapple;

import com.tattyseal.zaet.proxy.IProxy;

import cpw.mods.fml.common.FMLCommonHandler;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.common.event.FMLServerStartingEvent;

import cpw.mods.fml.common.registry.GameRegistry;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.Item;

import org.apache.logging.log4j.Logger;

 

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

 

import java.io.File;

 

@Mod(modid = Zaet.MOD_ID, name = Zaet.MOD_NAME, version = "", useMetadata = true, guiFactory = "com.tattyseal.zaet.configuration.ConfigGuiFactory")

public class Zaet

{

    public static final String MOD_ID = "zaet";

    public static final String MOD_NAME = "Zaet";

    public static final String MOD_PACKAGE = "com.tattyseal.zaet";

 

    @SidedProxy(clientSide = MOD_PACKAGE + ".proxy.ClientProxy", serverSide = MOD_PACKAGE + ".proxy.ServerProxy", modId = MOD_ID)

    public static IProxy proxy;

 

    @Mod.Instance(value = MOD_ID)

    public static Zaet instance;

 

    public static CreativeTabs tabZaet;

 

    public static Item pineapple;

 

@EventHandler

public void preInitialization(FMLPreInitializationEvent fmlPreInitializationEvent)

{

        Config.init(new File("./config/zaet/config.cfg"));

 

        FMLCommonHandler.instance().bus().register(new ZaetHandler());

 

                tabZaet = new CreativeTabs("zaet")

        {

            public Item getTabIconItem()

            {

                return Zaet.pineapple;

            }

        };

 

        pineapple = new ItemPineapple();

}

 

    @EventHandler

    public void initialization(FMLInitializationEvent fmlInitializationEvent)

    {

    GameRegistry.registerItem(pineapple, "zaet.pineapple");

    }

 

    @EventHandler

    public void postInitialization(FMLPostInitializationEvent fmlPostInitializationEvent)

    {

 

    }

 

    @EventHandler

    public void serverStarting(FMLServerStartingEvent fmlServerStartingEvent)

    {

 

    }

}

 

 

 

 

Config

 

 

package com.tattyseal.zaet.configuration;

 

import net.minecraftforge.common.config.Configuration;

 

import java.io.File;

 

/**

* * @package com.tattyseal.zaet.configuration

* * This code was made by tattyseal on the 29/06/14 for Zaet

* *

*/

public class Config

{

    public static Configuration config;

 

    public static int textureSize;

 

    public static void init(File file)

    {

        config = new Configuration(file);

 

        syncConfig();

    }

 

    public static void syncConfig()

    {

        textureSize = config.get("textures", "textureSize", 64, "This has to be 16, 32, 48 or 64").getInt();

 

        if(config.hasChanged())

        {

            config.save();

        }

    }

}

 

 

 

 

EventHandler

 

 

package com.tattyseal.zaet.event;

 

import com.tattyseal.zaet.configuration.Config;

import cpw.mods.fml.client.event.ConfigChangedEvent;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

 

/**

* * @package com.tattyseal.zaet.event

* * This code was made by tattyseal on the 29/06/14 for Zaet

* *

*/

public class ZaetHandler

{

    @SubscribeEvent

    public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent onConfigChangedEvent)

    {

        if(onConfigChangedEvent.modID.equals("zaet"))

        {

            Config.syncConfig();

        }

    }

}

 

 

 

 

GuiFactory

 

 

package com.tattyseal.zaet.configuration;

 

import cpw.mods.fml.client.IModGuiFactory;

import net.minecraft.client.Minecraft;

import net.minecraft.client.gui.GuiScreen;

 

import java.util.Set;

 

/**

* * @package com.tattyseal.zaet.configuration

* * This code was made by tattyseal on the 30/06/14 for Zaet

* *

*/

public class ConfigGuiFactory implements IModGuiFactory

{

 

    @Override

    public void initialize(Minecraft minecraftInstance) {

 

    }

 

    @Override

    public Class<? extends GuiScreen> mainConfigGuiClass() {

        return ZaetConfigGUI.class;

    }

 

    @Override

    public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {

        return null;

    }

 

    @Override

    public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {

        return null;

    }

}

 

 

 

 

Config GUI

 

 

package com.tattyseal.zaet.configuration;

 

import cpw.mods.fml.client.config.GuiConfig;

import net.minecraft.client.gui.GuiMainMenu;

import net.minecraft.client.gui.GuiScreen;

import net.minecraftforge.common.config.ConfigElement;

 

/**

* * @package com.tattyseal.zaet.configuration

* * This code was made by tattyseal on the 30/06/14 for Zaet

* *

*/

public class ZaetConfigGUI extends GuiConfig

{

    public ZaetConfigGUI()

    {

        super(new GuiMainMenu(), new ConfigElement(Config.config.getCategory("textures")).getChildElements(), "zaet", false, false, "./config/zaet/config.cfg");

    }

}

 

 

 

Link to comment
Share on other sites

I'm somewhat suspicious that there may be a problem in this part of your code, in your config GUI class:

public class ZaetConfigGUI extends GuiConfig
{
    public ZaetConfigGUI()
    {
        super(new GuiMainMenu(), new ConfigElement(Config.config.getCategory("textures")).getChildElements(), "zaet", false, false, "./config/zaet/config.cfg");
    }
}

I have a simpler config GUI working and the code for mine looks like:

    public WildAnimalsConfigGUI(GuiScreen parent) 
    {
        super(parent,
                new ConfigElement(WildAnimals.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(),
                WildAnimals.MODID, false, false, GuiConfig.getAbridgedConfigPath(WildAnimals.config.toString()));
    }

I understand that some of the differences are simply due to the way you've set up your class structure, so may not be a problem.  But it might be good to break down this line a bit to see if it is doing what you expect.  In particular, see if the category is working, maybe try using a built in category to see if you can get that working first, maybe double check the config file path and maybe try doing it with the abridged config path method I used.

 

I just feel that the problem is somewhere in this line.  Just a hunch, but a lot has to be working right for this line to execute as expected.

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

Link to comment
Share on other sites

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.