Jump to content

Recommended Posts

Posted

As I have no experiences thus far with config files, I tried to make one, yet failed. Here is the complete set of code for the ConfigHandler:

package mardiff.quartz.lib;

import java.io.File;

import net.minecraftforge.common.Configuration;

public class ConfigHandler {
public static void init(File configFile) {
	Configuration config = new Configuration(configFile);

	config.load();

	//Blocks
	BlockIds.QUARTZ_CRYSTAL_BLOCK = config.getBlock("Quartz Crystal Block", BlockIds.QUARTZ_CRYSTAL_BLOCK_DEFAULT).getInt();
	//BlockIds.QUARTZ_ORE = config.getBlock(Quartz Block, BlockIds.QUARTZ_ORE_DEFAULT).getInt();

	//Items
	ItemIds.QUARTZ_SWORD = config.getItem("Quartz Sword", ItemIds.QUARTZ_SWORD_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_SHOVEL = config.getItem("Quartz Shovel", ItemIds.QUARTZ_SHOVEL_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_PICK = config.getItem("Quartz Pickaxe", ItemIds.QUARTZ_PICK_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_AXE = config.getItem("Quartz Axe", ItemIds.QUARTZ_AXE_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_HOE = config.getItem("Quartz Hoe", ItemIds.QUARTZ_HOE_DEFAULT).getInt() - 256;

	ItemIds.QUARTZ_HELM = config.getItem("Quartz Helm", ItemIds.QUARTZ_HELM_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_CHEST = config.getItem("Quartz Chest", ItemIds.QUARTZ_CHEST_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_LEGS = config.getItem("Quartz Legs", ItemIds.QUARTZ_LEGS_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_BOOTS = config.getItem("Quartz Boots", ItemIds.QUARTZ_BOOTS_DEFAULT).getInt() - 256;

	ItemIds.QUARTZ_CHISEL = config.getItem("Diamond Chisel", ItemIds.QUARTZ_CHISEL_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_CARVED_QUARTZ = config.getItem("Quartz Crystal", ItemIds.QUARTZ_CARVED_QUARTZ_DEFAULT).getInt() - 256;

	config.save();
}
}

 

Addtionally, this line is in the PreInit of my main class:

ConfigHandler.init(event.getSuggestedConfigurationFile());

 

The problem is that when I try to open an existing world or make a new one, instead of giving me an error, the game simply kicks the game out to the title screen, and only then when you open the world again does it freeze the console. The console doesn't give any errors, so that doesn't help, and the config file itself looks just like it should. Any help would be appreciated.

Thanks,

Mardiff

If you really want help, give that modder a thank you.

 

Modders LOVE thank yous.

Posted

Not sure if you set your config file up right, Here is the way I have mine set up

 

Main class

 

  Reveal hidden contents

 

 

block Ids

 

  Reveal hidden contents

 

if (You.likescoding == false){
      You.goaway;
}

Posted

Try using config.get() instead of config.getBlock or config.getItem:

 

myBlockID = config.get(config.CATEGORY_BLOCK, "myBlockID", 1000).getInt();

 

The methods you're using are expecting a String comment parameter that you're not passing which might be problematic.

 

    public Property getItem(String category, String key, int defaultID, String comment)
    {
        Property prop = get(category, key, -1, comment);

Posted
  On 9/17/2013 at 8:26 AM, Lycanus Darkbinder said:

Try using config.get() instead of config.getBlock or config.getItem:

 

myBlockID = config.get(config.CATEGORY_BLOCK, "myBlockID", 1000).getInt();

 

The methods you're using are expecting a String comment parameter that you're not passing which might be problematic.

 

    public Property getItem(String category, String key, int defaultID, String comment)
    {
        Property prop = get(category, key, -1, comment);

 

It worked! Thanks!

If you really want help, give that modder a thank you.

 

Modders LOVE thank yous.

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.