Jump to content

Huge config problem


ss7

Recommended Posts

Hello,

 

I have got to a point where i would like to make a config file. I found a tutorial in the wiki section. First i'm going to show you how i create my blocks and items in my main mod file:

 

public static final Block test = new Test(Config.ids.get(0), Material.ground).setUnlocalizedName("test");

 

In my Config file i have this (the var called ids is a ArrayList<Integer> where i save all my ids):

 

 

static void LoadConfig(Configuration config)

{

config.load();

 

ids.add(config.get(Configuration.CATEGORY_BLOCK, "Test", 3717).getInt());

 

config.save();

}

 

 

The LoadConfig() function is called in the FMLPreInitializationEvent like this:

 

Config.LoadConfig(new Configuration(event.getSuggestedConfigurationFile()));

 

Unfortunately this won't work, cause the block is created before the Config.ids list gets his ids, so it throws a NPE.

 

So i solved that problem like this:

 

In my mod file:

 

public static Block test;

 

And in the FMLInitializationEvent:

 

test = new Test(Config.ids.get(0), Material.ground).setUnlocalizedName("test");

 

But that also doesn't work, because some of my mod files need access to the Test.blockID before the mod is initialized.

 

So i have no idea what i should do to fix this problem.

 

I hope you can help!

 

Thanks in advance!

 

ss7

You sir are a god damn hero.

Link to comment
Share on other sites

Hello,

 

OH, thank you. I had this line in my Config class:

 

RECIPES.put(Item.coal.itemID, Brickcraft.test.blockID);

 

So i've got a NPE, but to solve it i've just made a method that's called after the blocks are initialized and it's working fine.

 

This is now

 

SOLVED

 

ss7

You sir are a god damn hero.

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.