Jump to content

java.lang.NullPointerException


Thecheatgamer1

Recommended Posts

Well this is my ModBlocks.java

 

 

package com.Thecheatgamer1.Annom.Block;

 

import net.minecraft.block.Block;

import net.minecraft.item.ItemStack;

import net.minecraftforge.common.MinecraftForge;

 

import com.Thecheatgamer1.Annom.Lib.BlockIds;

import com.Thecheatgamer1.Annom.Lib.ItemIds;

import com.Thecheatgamer1.Annom.Lib.Strings;

 

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

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

 

public class ModBlocks {

 

    /* Mod block instances */

    public static Block fusionore;

    public static Block iredantblock;

 

 

    public static void init() {

 

        fusionore = new BlockFusionOre(BlockIds.FUSIONORE);

        iredantblock = new BlockFusionOre(BlockIds.IREDANTBLOCK);

 

        GameRegistry.registerBlock(fusionore, Strings.FUSIONORE_NAME);

        GameRegistry.registerBlock(iredantblock, Strings.IREDANTBLOCK_NAME);

       

        LanguageRegistry.addName(fusionore, "Fusion ore");

        LanguageRegistry.addName(iredantblock, "Fusion ore");

       

        MinecraftForge.setBlockHarvestLevel(fusionore, "shovel", 0);

       

        initBlockRecipes();

    }

   

    private static void initBlockRecipes() {

 

        GameRegistry.addRecipe(new ItemStack(iredantblock), new Object[] { "aaa", "aaa", "aaa", Character.valueOf('a'), ItemIds.ITEMIREDANTCRYSTAL });

    }

}

 

 

 

This is my BlockIredantBlock.java

 

 

package com.Thecheatgamer1.Annom.Block;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

 

import com.Thecheatgamer1.Annom.Lib.Textures;

 

 

public class BlockIredantBlock extends Block {

   

 

    public BlockIredantBlock (int id, int texture, Material material) {

            super(id, material);

           

            this.stepSound = soundPowderFootstep;

            this.blockParticleGravity = 0.5F;

            this.slipperiness = 5.0F;

            this.blockHardness = 1;

    }

 

   

    public String getTextureFile()

    {

        return Textures.BLOCKIREDANTBLOCK;

    }

}

 

 

And this is my BlockFusionOre.java

 

 

package com.Thecheatgamer1.Annom.Block;

 

import java.util.Random;

 

import com.Thecheatgamer1.Annom.Annom.Annom;

import com.Thecheatgamer1.Annom.Lib.ItemIds;

import com.Thecheatgamer1.Annom.Lib.Textures;

 

import net.minecraft.block.Block;

import net.minecraft.block.BlockOre;

 

public class BlockFusionOre extends BlockOre {

 

    public BlockFusionOre(int id) {

        super(id);

       

        setHardness(4.0F); // 33% harder than diamond

        setStepSound(Block.soundStoneFootstep);

        setCreativeTab(Annom.tabsAnnom);

}

 

    public String getTextureFile() {

        return Textures.BLOCKIREDANTBLOCK;

    }

 

    public int idDropped(int par1, Random random, int par2) {

        return ItemIds.ITEMFUSIONINGOT;

    }

}

 

 

 

And when i try to run minecraft with how ever i try to fix it, this comes up :o

 

 

2013-06-18 17:15:55 [sEVERE] [ForgeModLoader]

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

FML{5.2.2.684} [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized

Forge{7.8.0.684} [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized

Annom{DEV Build!} [Annom] (bin) Unloaded->Constructed->Errored

2013-06-18 17:15:55 [sEVERE] [ForgeModLoader] The following problems were captured during this phase

2013-06-18 17:15:55 [sEVERE] [ForgeModLoader] Caught exception from Annom

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 com.Thecheatgamer1.Annom.Block.ModBlocks.initBlockRecipes(ModBlocks.java:39)

at com.Thecheatgamer1.Annom.Block.ModBlocks.init(ModBlocks.java:34)

at com.Thecheatgamer1.Annom.Annom.Annom.preInit(Annom.java:62)

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.propogateStateMessage(LoadController.java:165)

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

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

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

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

at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44)

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

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

2013-06-18 17:15:55 [iNFO] [sTDERR] java.lang.NullPointerException

2013-06-18 17:15:55 [iNFO] [sTDERR] at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:213)

2013-06-18 17:15:55 [iNFO] [sTDERR] at cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:244)

2013-06-18 17:15:55 [iNFO] [sTDERR] at cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:239)

2013-06-18 17:15:55 [iNFO] [sTDERR] at com.Thecheatgamer1.Annom.Block.ModBlocks.initBlockRecipes(ModBlocks.java:39)

2013-06-18 17:15:55 [iNFO] [sTDERR] at com.Thecheatgamer1.Annom.Block.ModBlocks.init(ModBlocks.java:34)

2013-06-18 17:15:55 [iNFO] [sTDERR] at com.Thecheatgamer1.Annom.Annom.Annom.preInit(Annom.java:62)

2013-06-18 17:15:55 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-06-18 17:15:55 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-06-18 17:15:55 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-06-18 17:15:55 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-06-18 17:15:55 [iNFO] [sTDERR] at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:494)

2013-06-18 17:15:55 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-06-18 17:15:55 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-06-18 17:15:55 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-06-18 17:15:55 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-06-18 17:15:55 [iNFO] [sTDERR] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

2013-06-18 17:15:55 [iNFO] [sTDERR] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

2013-06-18 17:15:55 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

2013-06-18 17:15:55 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

2013-06-18 17:15:55 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.post(EventBus.java:267)

2013-06-18 17:15:55 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:165)

2013-06-18 17:15:55 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-06-18 17:15:55 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-06-18 17:15:55 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-06-18 17:15:55 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-06-18 17:15:55 [iNFO] [sTDERR] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

2013-06-18 17:15:55 [iNFO] [sTDERR] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

2013-06-18 17:15:55 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

2013-06-18 17:15:55 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

2013-06-18 17:15:55 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.post(EventBus.java:267)

2013-06-18 17:15:55 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:98)

2013-06-18 17:15:55 [iNFO] [sTDERR] at cpw.mods.fml.common.Loader.loadMods(Loader.java:514)

2013-06-18 17:15:55 [iNFO] [sTDERR] at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:160)

2013-06-18 17:15:55 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.startGame(Minecraft.java:410)

2013-06-18 17:15:55 [iNFO] [sTDERR] at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44)

2013-06-18 17:15:55 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:732)

2013-06-18 17:15:55 [iNFO] [sTDERR] at java.lang.Thread.run(Unknown Source)

 

Link to comment
Share on other sites

I'm not sure why you are trying to pass in an object array thing when you make your recipe. The recipe format will probably be more like:

GameRegistry.addRecipe(new ItemStack(iredantblock), "aaa", "aaa", "aaa", 'a', new ItemStack(YourModItemsClass.iredantcrystal));

Assuming irredant crystal is a variable that has been made somewhere else that you can access.

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

Link to comment
Share on other sites

I'm not sure why you are trying to pass in an object array thing when you make your recipe. The recipe format will probably be more like:

GameRegistry.addRecipe(new ItemStack(iredantblock), "aaa", "aaa", "aaa", 'a', new ItemStack(YourModItemsClass.iredantcrystal));

Assuming irredant crystal is a variable that has been made somewhere else that you can access.

 

Changed it to that fix and this comes up

 

 

java.lang.NullPointerException

at net.minecraft.item.ItemStack.<init>(ItemStack.java:67)

at com.Thecheatgamer1.Annom.Block.ModBlocks.initBlockRecipes(ModBlocks.java:39)

at com.Thecheatgamer1.Annom.Block.ModBlocks.init(ModBlocks.java:34)

at com.Thecheatgamer1.Annom.Annom.Annom.preInit(Annom.java:113)

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.propogateStateMessage(LoadController.java:165)

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

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

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

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

at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44)

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

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

 

Link to comment
Share on other sites

I'm not sure why you are trying to pass in an object array thing when you make your recipe.

 

It doesn't matter. Java's infinite parameter feature is implemented to be backwards-compatible. In fact, when you have

 

GameRegistry.addRecipe(ItemStack, Object...)

You have nothing but

GameRegistry.addRecipe(ItemStack, Object[])

 

Java simply does the conversion for you behind the scenes. This actually is quite a neat feature since it allows you to programmatically assemble your recipes and still turn them in to that method. Example:

 

List<Object> myRecipe = new ArrayList<Object>();
myRecipe.add(new ItemStack(4, 1, 1));
myRecipe.addAll(new String[] { "aaa", "aaa", "aaa" });
myRecipe.add("a");
myRecipe.add(Block.blocksList[4]);
GameRegistry.addRecipe(myRecipe.toArray(new Object[0]));

 

Back to topic. Without further information I can only guess.

 

The erroring line in the CraftingManager is:

aitemstack[i1] = ((ItemStack)hashmap.get(Character.valueOf(c0))).copy();

 

The reason why this code fails is simple:

 

if (par2ArrayOfObj[i + 1] instanceof Item)
            {
                itemstack1 = new ItemStack((Item)par2ArrayOfObj[i + 1]);
            }
            else if (par2ArrayOfObj[i + 1] instanceof Block)
            {
                itemstack1 = new ItemStack((Block)par2ArrayOfObj[i + 1], 1, 32767);
            }
            else if (par2ArrayOfObj[i + 1] instanceof ItemStack)
            {
                itemstack1 = (ItemStack)par2ArrayOfObj[i + 1];
            }

(lines 189-200 of the CraftingManager).

This explicitly shows that you MUST pass in either an ItemStack, a Block, or an Item, but you are passing in an Integer.

 

Change

GameRegistry.addRecipe(new ItemStack(iredantblock), new Object[] { "aaa", "aaa", "aaa", Character.valueOf('a'), ItemIds.ITEMIREDANTCRYSTAL });

 

to

 

GameRegistry.addRecipe(new ItemStack(iredantblock), new Object[] { "aaa", "aaa", "aaa", Character.valueOf('a'), Item.itemsList[itemIds.ITEMIREDENTCRYSTAL + 256] });

 

where 256 represents the shifted index which still hasn't been fixed to be 4096. This is also the reason why you still can't go above 256 blocks...

 

Changed it to that fix and this comes up

 

You hit copy&paste, didn't you? Change

new ItemStack(YourModItemsClass.iredantcrystal)

to

new ItemStack(ItemIds.IREDANTCRYSTAL)

and you should be fine.

Link to comment
Share on other sites

You hit copy&paste, didn't you? Change

new ItemStack(YourModItemsClass.iredantcrystal)

to

new ItemStack(ItemIds.IREDANTCRYSTAL)

and you should be fine.

 

Taking a stab in the dark, I'm going to say that this might not work, Also

new ItemStack(YourModItemsClass.iredantcrystal)

is valid and is probably better to use. Also it is likely that ItemIds.IREDANTCRYSTAL will be itemID - 256 (because of shifted index and stuff), so lookup will fail, can't say for certain as this code isn't given

 

Again i'm going to re-state my thought that it is the item not being initialized at this point, i.e. if you haven't called ModItems.init() or whatever you called it the variables will be null, hence the null pointer, Also this is thrown using the Id as this is used to look up the item from an array of all the items, where it will be unable to find an item with your itemID. Try calling this method later than you already are (so like this):

 

@Init
public static void init(FMLInitializationEvent evt)
{
ModBlocks.init();
ModItems.init();
ModBlocks.initBlockRecipies();
}

Link to comment
Share on other sites

You hit copy&paste, didn't you? Change

new ItemStack(YourModItemsClass.iredantcrystal)

to

new ItemStack(ItemIds.IREDANTCRYSTAL)

and you should be fine.

 

Taking a stab in the dark, I'm going to say that this might not work, Also

new ItemStack(YourModItemsClass.iredantcrystal)

is valid and is probably better to use. Also it is likely that ItemIds.IREDANTCRYSTAL will be itemID - 256 (because of shifted index and stuff), so lookup will fail, can't say for certain as this code isn't given

 

Again i'm going to re-state my thought that it is the item not being initialized at this point, i.e. if you haven't called ModItems.init() or whatever you called it the variables will be null, hence the null pointer, Also this is thrown using the Id as this is used to look up the item from an array of all the items, where it will be unable to find an item with your itemID. Try calling this method later than you already are (so like this):

 

@Init
public static void init(FMLInitializationEvent evt)
{
ModBlocks.init();
ModItems.init();
ModBlocks.initBlockRecipies();
}

 

its still doing the same crash!

Link to comment
Share on other sites

Try to solve it yourself logically then. Split the line which is causing the error across several lines, this being java you can just hit enter between the parameters and it should work. This will tell you what is causing the error more precisely as each part will have a different line number and then you can track it down better.

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.

Announcements



×
×
  • Create New...

Important Information

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