Posted July 4, 201312 yr This baffles me completely. I get an error when I use the GameRegistry with my new item but if I don't register it, it works just fine. All Code needed: The items code. public static Item joint = new ItemFood(3420, -1, 0.1F, false).setPotionEffect(Potion.hunger.id, 90, 0, 1.0F).setAlwaysEdible().setCreativeTab(tabPotMod).setUnlocalizedName("joint"); The actual code that registers it. @Init public void load(FMLInitializationEvent evt) { LanguageRegistry.addName(joint, "Joint"); GameRegistry.registerItem(joint, "joint"); LanguageRegistry.instance().addStringLocalization("itemGroup.tabPotMod", "en_US", "Pot Mod"); } Error Report: ---- Minecraft Crash Report ---- // Hi. I'm Minecraft, and I'm a crashaholic. Time: 7/4/13 5:15 PM Description: Failed to start game java.lang.NullPointerException at cpw.mods.fml.common.registry.ItemData.setName(ItemData.java:158) at cpw.mods.fml.common.registry.GameData.setName(GameData.java:255) at cpw.mods.fml.common.registry.GameRegistry.registerItem(GameRegistry.java:150) at cpw.mods.fml.common.registry.GameRegistry.registerItem(GameRegistry.java:138) at hotrods20.potmod.PMMain.load(PMMain.java:59) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:494) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) at com.google.common.eventbus.EventBus.post(EventBus.java:267) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:192) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:172) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) at com.google.common.eventbus.EventBus.post(EventBus.java:267) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:103) at cpw.mods.fml.common.Loader.initializeMods(Loader.java:691) at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:213) at net.minecraft.client.Minecraft.startGame(Minecraft.java:448) at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44) at net.minecraft.client.Minecraft.run(Minecraft.java:733) at java.lang.Thread.run(Unknown Source) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.5.2 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_17, Oracle Corporation Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 819001760 bytes (781 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Suspicious classes: FML and Forge are installed IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v7.51 FML v5.2.23.737 Minecraft Forge 7.8.1.737 5 mods loaded, 5 mods active mcp{7.51} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized FML{5.2.23.737} [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized->Initialized Forge{7.8.1.737} [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized->Initialized ObsidianTools{1.0.0} [Obsidian Tools] (bin) Unloaded->Constructed->Pre-initialized->Initialized potMod{1.0.0} [Pot Mod] (bin) Unloaded->Constructed->Pre-initialized->Errored LWJGL: 2.4.2 OpenGL: GeForce GTX 670/PCIe/SSE2 GL version 4.3.0, NVIDIA Corporation Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Texture Pack: Default Profiler Position: N/A (disabled) Vec3 Pool Size: ~~ERROR~~ NullPointerException: null http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you.
July 4, 201312 yr 1 ahahahha best item ever !!1 2 whichc version of forge? for mc 1.6+ ? it goes in the preinit now how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
July 4, 201312 yr Author Lol, thank you for that. On the topic of fixing it, it is for the latest for 1.5.2. Not sure if latest so just in case: 5.2.23.737 http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you.
July 4, 201312 yr GameRegistry.registerItem(joint, "joint"); LanguageRegistry.addName(joint, "Joint"); LanguageRegistry.instance().addStringLocalization("itemGroup.tabPotMod", "en_US", "Pot Mod"); could it be because youre adding the name before the item like this ^ i love how you made that if you eat it you get the munchies how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
July 4, 201312 yr Author No, my other mod ObsidianTools does it the same exact way without error. http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you.
July 4, 201312 yr cant tell, guess you're gonna have to follow the stack trace and see whats causing the NPE how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
July 4, 201312 yr Author Well, thank you for your help. Question though, is it possible because I have 2 mods coded in one Eclipse mod environment? http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you.
July 4, 201312 yr yeah fo sho, basicly me and my friends are doing 1 big mod, but its technicly like 8 different mods in 1 workspace how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
July 5, 201312 yr Author Okay, that helps me some. I guess I'll just go look around the code for a bit and see if I can find anything out. I have found something interesting, when I register my joint item under my other mods name: GameRegistry.registerItem(joint, "joint", "ObsidianTools"); I receive no errors. Now if I do: GameRegistry.registerItem(joint, "joint", "PotMod"); It craps out an error. Now I am full of WTF... http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you.
July 5, 201312 yr Author I did that at first and still got the errors. http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you.
July 5, 201312 yr Author This is for 1.5.2. Everything should work right in the init par the fact that all my other items in OT are working just fine in init but I will try Pre-Init. EDIT, Pre-Init doesn't work either. I know what it says the error is but my mod is fully created but won't seem to work. http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you.
July 5, 201312 yr Author @Init public void load(FMLInitializationEvent evt) { GameRegistry.registerItem(joint, "joint", "PotMod"); LanguageRegistry.addName(joint, "Joint"); LanguageRegistry.instance().addStringLocalization("itemGroup.tabPotMod", "en_US", "Pot Mod"); } I do it the same exact way in ObsidianTools as I do it in PotMod. PM gets an error but OT doesn't. If I change the "PotMod" part of the registration code to "ObsidianTools", then it works just fine. http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you.
July 5, 201312 yr Author So... putting that in PreInit worked(confused). It is odd because with OTMain, my items are created as the mod is constructed and without any error. http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you.
July 5, 201312 yr @diesieben using @Sideonly is the equivalent of this try{ if(side is server){ throw new exception(); } }catch(Exception e){ e.printStackTrace(); } i agree that you should not have million of them. but they can be usefull for debugging and understanding what goes where how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
July 5, 201312 yr ? wont a Class/Method/FieldNotFoundException be thrown only if a parent/herited class/method has already the @Sideonly annotation? and if they do. adding it again wouldnt change anything. unless im wrong calling a function with @Sideonly will throw a NotFoundEx only if you're calling it from the wrong side as opposed to calling the method/wtv with the try/catch will throw the exception if its called from the wrong side BUT will not crash the server/client and like i said, debugging, lets not make @sideonly a religion how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
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.