Jump to content

1.7.2 - There is a bug on the crafting recipes code and I can't see where it is


pta2002

Recommended Posts

Hey, I am almost ending my mod and it was working fine when I run Minecraft to see if the craftable enchanted items where working (They worked) and then I decided to add one more item. I put it there, all fine but when I run the game, it crashed with the error: NullPointerException. All the times I got this error, I fixed it (always in the crafting). I removed all the shaped crafting code and Minecraft launched. I put the code back and I removed the recipe I added for the item I created. But this time, it crashed. I tried to see where the error is, since Eclipse wasn't showing me any error icon, but I didn't found it.

Do, I'm asking you if you can tell me what's wrong in the crafting code.

Here it is:

 

GameRegistry.addRecipe(new ItemStack(EmeraldHoe,1), new Object[] {"EE"," S "," S ",'E', Items.emerald, 'S', Items.stick});

    GameRegistry.addRecipe(new ItemStack(EmeraldAxe,1), new Object[] {"EE ","ES "," S ",'E', Items.emerald, 'S', Items.stick});

    GameRegistry.addRecipe(new ItemStack(EmeraldAxe,1), new Object[] {" EE"," SE"," S ",'E', Items.emerald, 'S', Items.stick});

    ItemStack stack = new ItemStack(NetherSword,1);

    stack.addEnchantment(Enchantment.fireAspect, 10);

    GameRegistry.addRecipe(stack,

    "X",

    "X",

    "B",'X', NetherIngot, 'B', Items.blaze_rod);

    GameRegistry.addRecipe(new ItemStack(FusionGem,1), new Object[] {" D ","SEO"," E ",'D', Items.diamond,'S', SapphireGem,'E', Items.emerald,'O', Blocks.obsidian});

    GameRegistry.addRecipe(new ItemStack(EmeraldPick,1), new Object[] {"XXX"," S "," S ", 'X', Items.emerald, 'S', Items.stick});

    GameRegistry.addRecipe(new ItemStack(EmeraldShovel,1), new Object[] {"X","S","S",'X', Items.emerald, 'S', Items.stick});

    GameRegistry.addRecipe(new ItemStack(EmeraldSword,1), new Object[] {"X","X","S",'X', Items.emerald, 'S', Items.stick});

    GameRegistry.addRecipe(new ItemStack(ObsidianShovel,1), new Object[] {

    "X","S","S",'X', Blocks.obsidian, 'S', Items.stick

    });

    ItemStack itemstack = new ItemStack(MegaPick, 1);

    itemstack.addEnchantment(Enchantment.efficiency, 2);

    GameRegistry.addRecipe(itemstack, "EOS", " F "," X ",'E', EmeraldPick,'O', ObsidianPick,'S', SapphirePick,'F', FusionGem,'X', Items.stick);

    GameRegistry.addRecipe(new ItemStack(ObsidianHoe,1), new Object[] {

    "XX","S","S",'X', Blocks.obsidian, 'S', Items.stick

    });

    GameRegistry.addRecipe(new ItemStack(ObsidianAxe,1), new Object[] {

    "XX ","XS "," S ",'X', Blocks.obsidian, 'S', Items.stick

    });

    GameRegistry.addRecipe(new ItemStack(ObsidianAxe,1), new Object[] {

    " XX"," SX"," S ",'X', Blocks.obsidian, 'S', Items.stick

    });

    GameRegistry.addRecipe(new ItemStack(ObsidianPick,1), new Object[] {

    "XXX"," S ","S", 'X', Blocks.obsidian, 'S', Items.stick

    });

    GameRegistry.addRecipe(new ItemStack(ObsidianSword,1), new Object[] {

    "X","X","S", 'X', Blocks.obsidian, 'S', Items.stick

    });

   

   

    GameRegistry.addRecipe(new ItemStack(SapphireBlock, 1), new Object[] {

   

    "XXX",

    "XXX",

    "XXX",'X', SapphireGem

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireAxe, 1), new Object[] {

   

    "XX ",

    "XS ",

    " S ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireAxe, 1), new Object[] {

   

    " XX",

    " SX",

    " S ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireHoe, 1), new Object[] {

    "XX ",

    " S ",

    " S ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireHoe, 1), new Object[] {

    " XX",

    " S ",

    " S ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphirePick, 1), new Object[] {

    "XXX",

    " S ",

    " S ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireShovel, 1), new Object[] {

    "X  ",

    "S  ",

    "S  ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireShovel, 1), new Object[] {

    " X ",

    " S ",

    " S ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireShovel, 1), new Object[] {

    "  X",

    "  S",

    "  S", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireSword, 1), new Object[] {

    "X  ",

    "X  ",

    "S  ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireSword, 1), new Object[] {

    " X ",

    " X ",

    " S ", 'X', SapphireGem, 'S', Items.stick

    });

   

    GameRegistry.addRecipe(new ItemStack(SapphireSword, 1), new Object[] {

    "  X",

    "  X",

    "  S", 'X', SapphireGem, 'S', Items.stick

    });

Link to comment
Share on other sites

For the love of god, you don't need 'new Object[]{'

Thats compiler spam just makes your code UGLY.

 

Anyways your issue is that one of moe of the Items you're using to inialize your ItemStacks is Null at the time you're making the recipe. Check your order of code and see if your item init code runs before this code.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Here it is: (WTF? // I'm sorry, Dave? Who is Dave?

---- Minecraft Crash Report ----

// I'm sorry, Dave.

 

Time: 08-06-2014 16:17

Description: Initializing game

 

java.lang.StringIndexOutOfBoundsException: String index out of range: 8

at java.lang.String.charAt(String.java:658)

at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:232)

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

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

at com.pta.plusmod.PlusMod.<init>(PlusMod.java:165)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

at java.lang.Class.newInstance(Class.java:374)

at cpw.mods.fml.common.ILanguageAdapter$JavaAdapter.getNewInstance(ILanguageAdapter.java:173)

at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:486)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)

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:208)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)

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:118)

at cpw.mods.fml.common.Loader.loadMods(Loader.java:491)

at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:204)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)

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

at net.minecraft.client.main.Main.main(Main.java:112)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at java.lang.String.charAt(String.java:658)

at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:232)

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

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

at com.pta.plusmod.PlusMod.<init>(PlusMod.java:165)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

at java.lang.Class.newInstance(Class.java:374)

at cpw.mods.fml.common.ILanguageAdapter$JavaAdapter.getNewInstance(ILanguageAdapter.java:173)

at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:486)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)

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:208)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)

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:118)

at cpw.mods.fml.common.Loader.loadMods(Loader.java:491)

at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:204)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)

 

-- Initialization --

Details:

Stacktrace:

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

at net.minecraft.client.main.Main.main(Main.java:112)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

 

-- System Details --

Details:

Minecraft Version: 1.7.2

Operating System: Windows 8 (x86) version 6.2

Java Version: 1.7.0_51, Oracle Corporation

Java VM Version: Java HotSpot Client VM (mixed mode), Oracle Corporation

Memory: 928241096 bytes (885 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v9.03 FML v7.2.209.1112 Minecraft Forge 10.12.1.1112 4 mods loaded, 4 mods active

mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed

FML{7.2.209.1112} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.1.1112.jar) Unloaded->Constructed

Forge{10.12.1.1112} [Minecraft Forge] (forgeSrc-1.7.2-10.12.1.1112.jar) Unloaded->Constructed

PlusMod{1.0} [PlusMod] (bin) Unloaded->Errored

Launched Version: 1.6

LWJGL: 2.9.0

OpenGL: Intel® HD Graphics GL version 4.0.0 - Build 10.18.10.3308, Intel

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Resource Packs: []

Current Language: English (US)

Profiler Position: N/A (disabled)

Vec3 Pool Size: ~~ERROR~~ NullPointerException: null

Anisotropic Filtering: Off (1)

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.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.