So I followed a tutorial displayed on here on how to organise a CreativeTab using Comparators and Item[] arrays.
The list is kept short and all for now, and I decided to run it just to get a glimpse on how the comparators will work out the list being displayed in the creative tab.
But I seem to be getting a NullPointerException...
I am guessing is because the custom creative tab file (NCTab.java) is trying to order items that have not been declared in the main class yet.
This is how mods main class works first before I show source code of both files.
1. Materials, CreativeTab, Blocks, and Items are initialised.
2. preInit(), custom code to check if mod is up to date and the CreativeTab gets some a parameter switched up [ ncTab.setNoScrollbar(); ]. Not going to have more stuff than what I already coded and I have a reasonable amount of space to disable the scroll bar. Then a world generator gets setup, fluid gets declared and registered (doesnt get registered later cause itll cause an NPE), Then blocks and items and tool get defined all in alphabetical order. (Blocks get ore defined first then their block). Next, GameRegistry registers the blocks, items, then tools. After that LanguageRegistry (I know I should not be using this anymore but I will replace it soon) adds the names for each block and item, then shapeless recipes are set up, then the shaped recipes, then the furnace recipes.
3. Init(), The events for buckets gets registered.
4. postInit(). outputs an "mod activated! message" showing the name and version, then a last check for update is done and logs one last time whether the mod is up to date or not.
Possible reasons for this NPE I think is either cause (going from most likely to least likely):
- All blocks and items should be declared in their proper class.
- I miscoded the Comparator when troubleshooting an error I got when following the text tutorial.
- The arrays are not setup properly as instead of using Array.asList(items...) I used Array.asList(new Item[]{items...}) as an alternative cause Array.asList(items...) gave a variable-type error.
Now here are the source files. Yes I am aware that I did squish in far too much code which is why I will now state that this mod is nowhere near even an 8th done. And yes I have been able to troubleshoot and fix every problem I have had (even with the fluid NPE) except for this one.
mod_NCElectromagnetism.java:
NCTab.java:
Any help is appreciated and thanks!