Jump to content

Recommended Posts

Posted

Hello!

 

I understand it may be frustrating when someone doesn't know what the hell they are doing, but I'm at my wits end. I'm getting an exception when I launch the game with my mod after trying to add oredictionary to my recipe.

 

Below is my code that is causing the crash.

 GameRegistry.addRecipe(new ItemStack(Block.wood,3),"x ","xx", 'x', "logWood");

 

Below is working code (that doesn't do what I'm trying to accomplish)

 GameRegistry.addRecipe(new ItemStack(Block.wood,3),"x ","xx", 'x', Block.wood);

 

The error is below.

 

 

2013-11-28 17:24:21 [sEVERE] [ForgeModLoader] Caught exception from UniversalWood

java.lang.NullPointerException

at net.minecraft.item.crafting.CraftingManager.func_92103_a(CraftingManager.java:213)

at cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:244)

at cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:239)

at universalwood.UniversalWood.load(UniversalWood.java:54)

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.GeneratedMethodAccessor3.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.func_71384_a(Minecraft.java:448)

at net.minecraft.client.MinecraftAppletImpl.func_71384_a(SourceFile:56)

at net.minecraft.client.Minecraft.run(Minecraft.java:733)

at java.lang.Thread.run(Unknown Source)

 

 

Thank you for any help you can give me. Sometimes I make myself tired..

 

EDIT: Here's what I was supposed to do:

GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Block.wood,3), true, new Object[]{"x ","xx", 'x', "logWood"}));

Posted

As far as i know, this "x ","xx", 'x', Block.wood works because it requires an item or a block.

This "x ","xx", 'x', "logWood" is using a string which the new recipe method wont accept.

If you want to use a custom item, instead of "logwood" follow the pattern of "Block.wood"

For example if your Block class is called MyBlocks, you would use: MyBlocks.logwood

It will prompt to import that class and it should work.

Hope this helps!

Posted

The "logWood" is an attempt to use the oredictionary entry for wood, in order to convert any type of wood added by mods into the dictionary into oak wood. It's an attempt to work around the fact that some mods don't use oredictionary in their recipes.

Posted

Ah ok i understand now. That wasnt clear in the original post. Unfortunately I can't really help you there, but keep in mind that recipes are looking for an item or block type, not a string type, so maybe there is a way round that for you.

Posted

Thank you! That gives me something to work with. If you are so inclined you can save me quite a bit of googling, trial and error and give me either a code snippet or a brief explanation, but you've already provided more than enough! Thank you!

Posted

Okay, some progress. The game no longer crashes when the mod is included. It is however not adding the recipe, as far as I can tell.

 

new ShapedOreRecipe(new ItemStack(Block.wood,3), true, new Object[]{"x ","xx", 'x', "logWood"});

Posted

Much progress! It is working! I implemented it wrong. My code declared that there was a new recipe, but didn't actually register it. For others with similar problem, here's what I did:

 

GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Block.wood,3), true, new Object[]{"x ","xx", 'x', "logWood"}));

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.