Dwargkiller Posted November 28, 2013 Posted November 28, 2013 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"})); Quote
AomicTim Posted November 28, 2013 Posted November 28, 2013 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! Quote
Dwargkiller Posted November 28, 2013 Author Posted November 28, 2013 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. Quote
AomicTim Posted November 28, 2013 Posted November 28, 2013 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. Quote
GotoLink Posted November 28, 2013 Posted November 28, 2013 You need to use a IRecipe implementation that supports the ore dictionary. For example, ShapedOreRecipe. Quote
Dwargkiller Posted November 28, 2013 Author Posted November 28, 2013 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! Quote
Dwargkiller Posted November 28, 2013 Author Posted November 28, 2013 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"}); Quote
Dwargkiller Posted November 28, 2013 Author Posted November 28, 2013 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"})); Quote
Recommended Posts
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.