Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Crafting recipe error when using custom items
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 2
sinsiliuxs120

Crafting recipe error when using custom items

By sinsiliuxs120, August 17, 2013 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

sinsiliuxs120    0

sinsiliuxs120

sinsiliuxs120    0

  • Tree Puncher
  • sinsiliuxs120
  • Members
  • 0
  • 9 posts
Posted August 17, 2013

So I've encountered this problem when I try to add a crafting recipe for item from my mod using other items from my mod minecraft crashes on start up. Eclipse doesn't show any errors and I'm not sure what to do. All my items are in base mod class as well as their crafting recipes. However items that are crafted with vanilla minecraft items work just fine. If you need any part of code just let me know. Thanks in advance

 

-S

  • Quote

Share this post


Link to post
Share on other sites

larsgerrits    510

larsgerrits

larsgerrits    510

  • Reality Controller
  • larsgerrits
  • Members
  • 510
  • 3455 posts
Posted August 17, 2013

You said that i should ask, so here it is: Code?

  • Quote

Share this post


Link to post
Share on other sites

sinsiliuxs120    0

sinsiliuxs120

sinsiliuxs120    0

  • Tree Puncher
  • sinsiliuxs120
  • Members
  • 0
  • 9 posts
Posted August 17, 2013

Here is the error code

---- Minecraft Crash Report ----

// I feel sad now :(

 

Time: 8/17/13 9:11 PM

Description: Failed to start game

 

java.lang.NullPointerException

        at net.minecraft.item.crafting.CraftingManager.addRecipe(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 mod.tdm.TdmBase.load(TdmBase.java:34)

        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)

 

  • Quote

Share this post


Link to post
Share on other sites

GotoLink    381

GotoLink

GotoLink    381

  • World Shaper
  • GotoLink
  • Members
  • 381
  • 2012 posts
Posted August 17, 2013

cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:239)
mod.tdm.TdmBase.load(TdmBase.java:34)

Error at line 34 of TdmBase.java, in the load method, at GameRegistry.addRecipe(args) you are giving a null.

  • Quote

Share this post


Link to post
Share on other sites

ILuvYouCompanionCube    6

ILuvYouCompanionCube

ILuvYouCompanionCube    6

  • Creeper Killer
  • ILuvYouCompanionCube
  • Members
  • 6
  • 112 posts
Posted August 17, 2013

check whether you are defining all the letters in your recipe, each letter is an ingredient. And check if all the items/blocks in the recipe are registered

  • Quote

Share this post


Link to post
Share on other sites

sinsiliuxs120    0

sinsiliuxs120

sinsiliuxs120    0

  • Tree Puncher
  • sinsiliuxs120
  • Members
  • 0
  • 9 posts
Posted August 18, 2013

All letters are defined, but I think that those items I used in crafting are unregistered. Could you explain it to me/give me a link where it's explained how to register items?

 

Edit: If you mean by typing public static ItemName under the public class BaseMod then yes I did that, for all items

  • Quote

Share this post


Link to post
Share on other sites

sinsiliuxs120    0

sinsiliuxs120

sinsiliuxs120    0

  • Tree Puncher
  • sinsiliuxs120
  • Members
  • 0
  • 9 posts
Posted August 18, 2013

Any ideas how to fix this? Anyone?

  • Quote

Share this post


Link to post
Share on other sites

bl4ckscor3    5

bl4ckscor3

bl4ckscor3    5

  • Stone Miner
  • bl4ckscor3
  • Members
  • 5
  • 86 posts
Posted August 18, 2013

The source code is very helpful on this.

  • Quote

Share this post


Link to post
Share on other sites

sinsiliuxs120    0

sinsiliuxs120

sinsiliuxs120    0

  • Tree Puncher
  • sinsiliuxs120
  • Members
  • 0
  • 9 posts
Posted August 19, 2013

Ok, I will put in the source code as soon as I come back.

  • Quote

Share this post


Link to post
Share on other sites

ashtonr12    3

ashtonr12

ashtonr12    3

  • Diamond Finder
  • ashtonr12
  • Members
  • 3
  • 479 posts
Posted August 19, 2013

this is how i did it :P

"GameRegistry.addRecipe(new ItemStack(ObsidianSword), " O "," O "," R ",'O', ashtonsmod.CondensedObsidian,'R',blazerod); "

  • Quote

Share this post


Link to post
Share on other sites

GotoLink    381

GotoLink

GotoLink    381

  • World Shaper
  • GotoLink
  • Members
  • 381
  • 2012 posts
Posted August 19, 2013

So, there are three possible null arguments:

-ObsidianSword

-CondensedObsidian

-blazerod

All those should be initialized before the addRecipe(args) line.

 

You can also try with

GameRegistry.addRecipe(new ItemStack(ObsidianSword), new Object[]{" O "," O "," R ",'O', ashtonsmod.CondensedObsidian,'R',blazerod});

  • Quote

Share this post


Link to post
Share on other sites

sinsiliuxs120    0

sinsiliuxs120

sinsiliuxs120    0

  • Tree Puncher
  • sinsiliuxs120
  • Members
  • 0
  • 9 posts
Posted August 20, 2013

Ok, so here is the BaseMod.class (TdmBase.java) code:

 

 

    package sins.tdm;

   

    import net.minecraft.block.Block;

    import net.minecraft.block.material.Material;

    import net.minecraft.creativetab.CreativeTabs;

    import net.minecraft.item.Item;

    import net.minecraft.item.ItemStack;

    import cpw.mods.fml.common.Mod;

    import cpw.mods.fml.common.Mod.Init;

    import cpw.mods.fml.common.event.FMLInitializationEvent;

    import cpw.mods.fml.common.network.NetworkMod;

    import cpw.mods.fml.common.registry.GameData;

    import cpw.mods.fml.common.registry.GameRegistry;

    import cpw.mods.fml.common.registry.LanguageRegistry;

    import net.minecraft.item.crafting.CraftingManager;

   

    @Mod(modid = TdmBase.modid, name = "Sorry no spoilers :)", version = "1.0")

    @NetworkMod(clientSideRequired = true, serverSideRequired = false)

    public class TdmBase

    {

   

            public static final String modid = "sins_TDM";

         

         

            public static CreativeTabs tabTDM = new CreativeTabs("tabTDM") {

            public ItemStack getIconItemStack() {

                    return new ItemStack(TdmBase.barrel, 1, 0);

            }

    };

         

            public static Block barrel;

            public static Item cog;

            public static Item woodenWheel;

            public static Item reinforcedWheel;

            public static Item smallCannon;

            public static Item woodenChassis;

            public static Item reinforcedChassis;

         

            @Init

            public void load(FMLInitializationEvent event)

            {

                    reinforcedChassis = new ItemReinforcedChassis(7210).setUnlocalizedName("Reinforced chassis");

                    LanguageRegistry.addName(reinforcedChassis, "Reinforced chassis");

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

                    "WIW","CBC","WIW", 'W', TdmBase.reinforcedWheel, 'I', Item.ingotIron, 'C', TdmBase.cog, 'B', Block.blockIron});

   

                    woodenChassis = new ItemWoodenChassis(7209).setUnlocalizedName("Wooden chassis");

                    LanguageRegistry.addName(woodenChassis, "Wooden chassis");

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

                    "WSW","CPC","WSW", 'W', TdmBase.woodenWheel, 'S', Item.stick, 'C', TdmBase.cog, 'P', Block.planks});

                 

                    smallCannon = new ItemSmallCannon(7208).setUnlocalizedName("Small cannon");

                    LanguageRegistry.addName(smallCannon, "Small cannon");

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

                    "I  "," I ","  I", 'I', Item.ingotIron});

                 

                    reinforcedWheel = new ItemReinforcedWheel(7207).setUnlocalizedName("Reinforced wheel");

                    LanguageRegistry.addName(reinforcedWheel, "Reinforced wheel");

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

                    "III","IPI","III", 'I', Item.ingotIron, 'P', Block.planks});

                 

                    woodenWheel = new ItemWoodenWheel(7206).setUnlocalizedName("Wooden wheel");

                    LanguageRegistry.addName(woodenWheel, "Wooden wheel");

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

                    "SSS","SPS","SSS", 'P', Block.planks, 'S', Item.stick});

                 

                    cog = new ItemCog(7205).setUnlocalizedName("Cog");

                    LanguageRegistry.addName(cog, "Cog");

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

                " S ","SPS"," S ", 'I', Block.planks, 'S', Item.stick});

                 

                    barrel = new BlockBarrel(500, Material.grass).setUnlocalizedName("Barrel").setHardness(2.0F).setResistance(0.0F).setStepSound(Block.soundWoodFootstep);

                    GameRegistry.registerBlock(barrel, modid + barrel.getUnlocalizedName2());

                    LanguageRegistry.addName(barrel, "Barrel");

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

            "PCP","PCP","PCP", 'P', Block.planks, 'C', Item.gunpowder});

                 

                    LanguageRegistry.instance().addStringLocalization("itemGroup.tabTDM", "en_US", "No spoilers :)))");

            }

    }

 

 

 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6693

diesieben07

diesieben07    6693

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6693
  • 45754 posts
Posted August 20, 2013

One example:

In the first addRecipe call you use TdmBase.cog, which is initialized a few lines after that call.

You can only use Items you have initialized!

  • Quote

Share this post


Link to post
Share on other sites

sinsiliuxs120    0

sinsiliuxs120

sinsiliuxs120    0

  • Tree Puncher
  • sinsiliuxs120
  • Members
  • 0
  • 9 posts
Posted August 20, 2013

Thank, you. This solved the problem :)

 

P.S. It wasn't necessary to use exclamation mark.

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 2
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • diesieben07
      [1.12.2] NBT inconsistencies

      By diesieben07 · Posted 1 minute ago

      Did you verify your tile entity was being saved? Or just the custom item?
    • BeardlessBrady
      [1.12.2] NBT inconsistencies

      By BeardlessBrady · Posted 2 minutes ago

      I was not, I added it to all the places I change the data and it did not change the issue unfortunately. 
    • diesieben07
      [1.12.2] NBT inconsistencies

      By diesieben07 · Posted 9 minutes ago

      Are you calling markDirty on your tile entity whenever you change it's data?
    • BeardlessBrady
      [1.12.2] NBT inconsistencies

      By BeardlessBrady · Posted 14 minutes ago

      I tried debugging the #toNBT and #fromNBT methods in my itemVendor class. It seems to only save the NBT when I pause the game for the very first time after first placing the block but when I quit the world it does not save the NBT nor does it do it when I pause any other time. It will however save NBT and load NBT on world startup... Any ideas?
    • diesieben07
      pw.mods.fml.common.LoaderException: java.lang.NoSuchFieldError: rock

      By diesieben07 · Posted 55 minutes ago

      1.7.10 is no longer supported on this forum due to it's age. Update to a modern version of Minecraft to receive support.
  • Topics

    • BeardlessBrady
      7
      [1.12.2] NBT inconsistencies

      By BeardlessBrady
      Started Yesterday at 04:12 AM

    • Baconator
      4
      pw.mods.fml.common.LoaderException: java.lang.NoSuchFieldError: rock

      By Baconator
      Started 4 hours ago

    • BruhSoundEffectNumberTwo
      1
      [1.14.4] How do I read a Jsonarray from a file?

      By BruhSoundEffectNumberTwo
      Started 1 hour ago

    • plugsmustard
      6
      JSON questions

      By plugsmustard
      Started Yesterday at 07:28 PM

    • meloncin
      1
      forge no me funciona

      By meloncin
      Started 3 hours ago

  • Who's Online (See full list)

    • diesieben07
    • Draco18s
    • plugsmustard
    • BatHeart
    • F43nd1r
    • BeardlessBrady
    • Blackout03
    • SerpentDagger
    • Mustacheman013
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Crafting recipe error when using custom items
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community