Jump to content

[SOLVED]GameRegistry causing error


hotrods20

Recommended Posts

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

 

width=320 height=64http://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.

Link to comment
Share on other sites

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-

Link to comment
Share on other sites

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

width=320 height=64http://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.

Link to comment
Share on other sites

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.

width=320 height=64http://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.

Link to comment
Share on other sites

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

width=320 height=64http://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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

?

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 xD

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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.