Jump to content

[1.7.2 - FIXED] Crafting Error NullPointerException


Recommended Posts

Posted

Hello guys.

 

Every time when I start Minecraft it crashed with an NullPointerException.

 

Error:

 

  Reveal hidden contents

 

 

Code:

 

  Reveal hidden contents

 

 

I'm using Java Version: 1.7.0_51 and  Minecraft Version: 1.7.2 and Minecraft Forge 10.12.0.1024.

 

I hope that you can help me.

Bektor

Developer of Primeval Forest.

Posted

Here is the full code of the method that makes the problem (well there are more errors, but this errors are only problems, because they load this method and then it crashed)

 

  Reveal hidden contents

 

Developer of Primeval Forest.

Posted
  Reveal hidden contents

Developer of Primeval Forest.

Posted

    		GameRegistry.addRecipe(new ItemStack(ARepo.ICobalt_door, 1), new Object[]
                    {
                        "#cc", "#cc", "#cc",
                        Character.valueOf('c'), CMStuff.cobaltwood
                    });

 

Uh.

 

You know that blank spaces in the crafting grid are defined with SPACES right?  The crafting manager is trying to figure out what the # means and can't find it.

 

Also you don't need to do new Object[] because of the way the recieving function is programmed:

 

addRecipe(ItemStack result, Object...)

 

That ... means that any parameters beyond the specified ones are already accessible as an array.

 

GameRegistry.addRecipe(new ItemStack(ARepo.ICobalt_door, 1), " cc", " cc", " cc", Character.valueOf('c'), CMStuff.cobaltwood);

 

BAM.

 

Also, that "character of" bit can also be removed.  In Java 'c' is a character already (whereas "c" is a string).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Same error.

 

Error:

 

  Reveal hidden contents

 

 

The new code:

 

  Reveal hidden contents

 

 

Oh and without the Character.valueOf I get the same error and without the SPACES the same error appears again.

Developer of Primeval Forest.

Posted

Show your main class.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 2/27/2014 at 8:23 PM, Draco18s said:

Show your main class.

 

 

  Reveal hidden contents

 

Developer of Primeval Forest.

Posted

Don't register your recipes in preInit.  Because of the way you've structured your mod, you can't insure that the class that is creating the blocks has created and registered them yet.  Move your recipes to Init or PostInit.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Same problems.

 

 

  Reveal hidden contents

 

 

Code:

 

  Reveal hidden contents

 

 

  Reveal hidden contents

 

 

 

  Reveal hidden contents

 

 

 

  Reveal hidden contents

 

 

Here is the API that I used from the Mod CobaltMod (the API isn't published yet, because the developer will now if its work and yes, the api isn't so optimal, but the mod developer and I havn't an idea, how a method must look, that the items and blocks must not public in an api....)

 

  Reveal hidden contents

 

Developer of Primeval Forest.

Posted

Hi

 

Are you sure you're using Forge version 1024?

 

In my version 1024, there is no func_92103_a and my CraftingManager.java:234 doesn't match yours

 

But anyway, I'm pretty certain that your CMSstuff.cobaltwood or CMSstuff.cobaltingot is still null at the point you construct your ARecipes.

 

Do you know how to use the integrated debugger? (Breakpoints and watches etc)?  If so, I'd suggest you put a breakpoint in your addRecipesForCraftingTable and inspect the values of cobaltwood and cobaltingot.

 

(If you don't know... it's well worth your time spending a couple of hours to learn, I reckon)

http://www.vogella.com/tutorials/EclipseDebugging/article.html

or

https://www.jetbrains.com/idea/webhelp/debugging.html

and

 

-TGG

 

 

Posted

As Draco18s has told you, don't put anything in the crafting strings that you don't explain except spaces ' ' or " ". They are the only things that provide empty ness, not "_" or any other wierd character.

If the grid has "A A" " B " and " C ", then you must have the characters 'A', 'B', and 'C' after the string and before an Item. If you use '#' in the grid, then you must use that before an Item, same with '_'.

 

The craftingManager cannot read your mind!

 

You still have this?

    GameRegistry.addRecipe(new ItemStack(ARepo.ICobalt_door, 1), "_##", "_ ##", "_ ##", Character.valueOf('#'), CMStuff.cobaltwood);
    GameRegistry.addRecipe(new ItemStack(ARepo.ICobalt_door, 1), "##_", "##_", "##_ ", Character.valueOf('#'), CMStuff.cobaltwood);
          
     GameRegistry.addRecipe(new ItemStack(ARepo.IIronCobalt_door, 1), "_ ##", "_##", "_##", Character.valueOf('#'), CMStuff.cobaltingot);
     GameRegistry.addRecipe(new ItemStack(ARepo.IIronCobalt_door, 1),"##_", "##_", "##_", Character.valueOf('#'), CMStuff.cobaltingot);

 

Change the underscores to spaces. Or, get rid of the entirely. You don't need them.

Posted
  On 2/28/2014 at 11:12 PM, sequituri said:

As Draco18s has told you, don't put anything in the crafting strings that you don't explain except spaces ' ' or " ". They are the only things that provide empty ness, not "_" or any other wierd character.

If the grid has "A A" " B " and " C ", then you must have the characters 'A', 'B', and 'C' after the string and before an Item. If you use '#' in the grid, then you must use that before an Item, same with '_'.

 

The craftingManager cannot read your mind!

 

You still have this?

    GameRegistry.addRecipe(new ItemStack(ARepo.ICobalt_door, 1), "_##", "_ ##", "_ ##", Character.valueOf('#'), CMStuff.cobaltwood);
    GameRegistry.addRecipe(new ItemStack(ARepo.ICobalt_door, 1), "##_", "##_", "##_ ", Character.valueOf('#'), CMStuff.cobaltwood);
          
     GameRegistry.addRecipe(new ItemStack(ARepo.IIronCobalt_door, 1), "_ ##", "_##", "_##", Character.valueOf('#'), CMStuff.cobaltingot);
     GameRegistry.addRecipe(new ItemStack(ARepo.IIronCobalt_door, 1),"##_", "##_", "##_", Character.valueOf('#'), CMStuff.cobaltingot);

 

Change the underscores to spaces. Or, get rid of the entirely. You don't need them.

Well I've tested it with "_" and without "_". Oh and with normal spaces: " " I've tested it too.

Developer of Primeval Forest.

Posted
  On 2/28/2014 at 11:09 PM, TheGreyGhost said:

Hi

 

Are you sure you're using Forge version 1024?

 

In my version 1024, there is no func_92103_a and my CraftingManager.java:234 doesn't match yours

 

But anyway, I'm pretty certain that your CMSstuff.cobaltwood or CMSstuff.cobaltingot is still null at the point you construct your ARecipes.

 

Do you know how to use the integrated debugger? (Breakpoints and watches etc)?  If so, I'd suggest you put a breakpoint in your addRecipesForCraftingTable and inspect the values of cobaltwood and cobaltingot.

 

(If you don't know... it's well worth your time spending a couple of hours to learn, I reckon)

http://www.vogella.com/tutorials/EclipseDebugging/article.html

or

https://www.jetbrains.com/idea/webhelp/debugging.html

and

 

-TGG

 

Ok, I had used now the debugger and the line "if(Loader.isModLoaded("mod_cobalt"))" was marked and Minecraft got a black screen.

Well, "CMSstuff.cobaltingot" is still null I think, because this items and blocks are not from my mod and I have only the API from this mod. But if I have recompiled it, that I have my mod as a .jar and the other mods and if I run with both Minecraft, the error appears again, but then "CMSstuff.cobaltingot" isn't null, because the other mod use and register it then. Oh and I had used Forge  version 1024 but then I updated to Forge 10.12.0.1032 for some reasons, but with both versions, this error appears.

Developer of Primeval Forest.

Posted

Unless you post the new log with the new code, there is no way for us to surmise what problems remain. So, post the latest crash log with your code that causes it. Then you will get more help.

Posted

The code and the crash is the same as befor. I tested only some new method with the CraftingManager, but I removed this methods again, because the same crash appeard. Well with I tested some new methods, I mean that I tested everything what all of you guys wanted that I use this method and test it then to see if the error is there then too.

Developer of Primeval Forest.

Posted
  On 3/1/2014 at 6:19 PM, coolboy4531 said:

Why the **** do you have 4 characters?

 

_ ##

 

Underscore, space, numbersign, numbersign?

 

Where see you the "****"? And what did you mean with "Underscore, space, numbersign, numbersign?"?

Developer of Primeval Forest.

Posted

So you went back to square one, which you knew did not work. Now, you expect us to glean something more from those old crashlogs? I'm pretty sure that you've ignored all of our help, you won't get much more.

 

Learn from what you've been told and try the results (with new logs and code) or fix it yourself.

Posted
  On 3/3/2014 at 7:14 PM, Bektor said:

  Quote

Why the **** do you have 4 characters?

 

_ ##

 

Underscore, space, numbersign, numbersign?

 

Where see you the "****"? And what did you mean with "Underscore, space, numbersign, numbersign?"?

The four asterisks were meant to censor a swear, they were not in the code.

Posted
  On 3/3/2014 at 7:47 PM, sequituri said:

So you went back to square one, which you knew did not work. Now, you expect us to glean something more from those old crashlogs? I'm pretty sure that you've ignored all of our help, you won't get much more.

 

Learn from what you've been told and try the results (with new logs and code) or fix it yourself.

 

Here is the code and the new log:

https://www.dropbox.com/sh/jc4b0brt5mihx5i/xEvZEYXiN9

 

I hope that you can help me know.

Developer of Primeval Forest.

Posted

        {
            GameRegistry.addRecipe(new ItemStack(ARepo.ICobalt_door, 1), "_##", "_ ##", "_ ##", Character.valueOf('#'), CMStuff.cobaltwood);
            GameRegistry.addRecipe(new ItemStack(ARepo.ICobalt_door, 1), "##_", "##_", "##_ ", Character.valueOf('#'), CMStuff.cobaltwood);
             
            GameRegistry.addRecipe(new ItemStack(ARepo.IIronCobalt_door, 1), "_##", "_##", "_##", Character.valueOf('#'), CMStuff.cobaltingot);
            GameRegistry.addRecipe(new ItemStack(ARepo.IIronCobalt_door, 1),"##_", "##_", "##_", Character.valueOf('#'), CMStuff.cobaltingot);
        }

Here is your problem. ^

The crafting grid is not correctly created in any of these recipes.

a. Only spaces and items go in the grid. Spaces are for alignment and structure. Nothing else.

b. You have underscores: They are not items and therefore do not belong in the grid. Nothing except spaces (for structure.) No underscores '_' allowed for this.

c. Your first recipe has 4 character wide strings. This will not give you the recipe you expect. Make all strings the same length (length of string <= 3 and all match).

d. You are registering recipes in 'preinit'. In 1.7.2, this should be done in 'init'.

 

Fix those and the problem goes away.

 

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.