Posted October 19, 201311 yr 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.
October 19, 201311 yr You found the solution. Don't access or set the block id before you can get it from your config file.
October 20, 201311 yr 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.