Jump to content

[SOLVED] Updating armor to 1.5


nerdboy64

Recommended Posts

I'm almost done updating one of my mods to 1.5, but I can't seem to get around one problem: armor. Eclipse doesn't give me any compiling errors, but when I run the game is crashes with a nullPointerException. Here is the error; I had to copy it from the command line since the game just gave a black screen:

2013-04-06 17:17:47 [iNFO] [sTDERR] Exception in thread "Minecraft main thread" java.lang.ExceptionInInitializerError
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at java.lang.Class.forName0(Native Method)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at java.lang.Class.forName(Unknown Source)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:446)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.post(EventBus.java:267)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:165)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.post(EventBus.java:267)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:98)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at cpw.mods.fml.common.Loader.loadMods(Loader.java:503)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:160)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.startGame(Minecraft.java:407)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.run(Minecraft.java:729)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at java.lang.Thread.run(Unknown Source)
2013-04-06 17:17:47 [iNFO] [sTDERR] Caused by: java.lang.NullPointerException
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at net.minecraft.item.ItemArmor.<init>(ItemArmor.java:50)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at advkit.ItemHeadlamp.<init>(ItemHeadlamp.java:12)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	at advkit.AdventureKit.<clinit>(AdventureKit.java:43)
2013-04-06 17:17:47 [iNFO] [sTDERR] 	... 29 more

 

Here is the constructor from the armor class:

public ItemHeadlamp(int par1) {
	super(par1, AdventureKit.special, 0, 0);

	setCreativeTab(CreativeTabs.tabTools);
}

 

Here is the EnumArmorMaterial from my main class:

public static EnumArmorMaterial special = EnumHelper.addArmorMaterial("SPECIAL", 1, new int[]{0,0,0,0}, 0);

All those zeros are because I don't want it to give any protection value, but simply exist as a flag that tells the mod to make light around the player.

 

I don't see what the problem could possibly be. If anyone has had this problem updating armor to 1.5, please tell me if you found the fix for this.

Link to comment
Share on other sites

I may be wrong but it looks like the origin of the error is in the static constructor of advkit.AdventureKit. And the error itself is a null reference being used as if it was not null. Do you initialize all you need in your advkit.AdventureKit static constructor? Maybe it's just my lack of expertise but for me the tiny pieces of code you posted are only enough for guessing.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Link to comment
Share on other sites

It does have a constructor, even if it's an implicit one. And more importantly to this situation, a static constructor.

 

advkit.AdventureKit.<clinit>: this is telling you that theres something wrong with the static constructor of advkit.AdventureKit, be either explicitly or implicitly, all types must be statically initialized (clinit stands for class initializer while init is your instance constructor). If you don't have an explicit static constructor, then check if all the static fields in your advkit.AdventureKit class are properly initialized before being statically referenced.

 

Also check advkit.ItemHeadlamp.<init> and net.minecraft.item.ItemArmor.<init>. Remember that the error stack is a stack. If some method A is one line above some other method B, it means A invoked B. So the origin of the error is the bottom of the stack.

 

The 2 little pieces of code you posted do seem fine. I think you are failing to notice something else.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Link to comment
Share on other sites

I am aware of how errors work. I did some more research, and it turns out that EnumHelper.addArmorMaterial is returning null, which rather throws a wrench into the works of the ItemArmor constructor. Unfortunately, I can't figure out what's actually wrong with my call of that method, so I still need help.

Link to comment
Share on other sites

After more experimentation, it seems like there's a problem with EnumHelper.addArmorMaterial. Turns out that, deep in the bowels of EnumHelper, is one of many methods called addEnum. I can't even begin to understand it, but it appears to be unable to find a field called "$VALUES," which prevents it from assigning the enum and thus returns null. I updated my MCP to the latest version of Forge SRC, and I still get this problem.

 

EDIT: I changed something--not really sure what--in EnumHelper and it works fine now.

Link to comment
Share on other sites

I copy-pasted your code and filled in with the missing registering and item instantiation, ran the game, and everything worked fine. So there's either something wrong with your minecraft/forge files or, as I said before, the error is somewhere else, not in those two harmless little pieces of code you posted.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

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.