Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

You found the solution. Don't access or set the block id before you can get it from your config file.

  • Author

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.