Jump to content

Recommended Posts

Posted

Every time i put the code in to craft a explosive i had made i get a java.lang.NullPointerException but if i don't put the crafting recipe it works fine.

 

2012-08-26 14:36:59 [iNFO] [sTDERR] Caused by: java.lang.NullPointerException

2012-08-26 14:36:59 [iNFO] [sTDERR] at net.minecraft.src.CraftingManager.addRecipe(CraftingManager.java:189)

2012-08-26 14:36:59 [iNFO] [sTDERR] at cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:181)

2012-08-26 14:36:59 [iNFO] [sTDERR] at reinforced.common.Reinforced_blocks.load(Reinforced_blocks.java:52)

 

 

 

 

naquadahbomb = new Naquadabomb(402,2).setStepSound(Block.soundPowderFootstep).setHardness(3F).setResistance(1.0F).setBlockName("Naquadah Bomb");

GameRegistry.registerBlock(naquadahbomb);

LanguageRegistry.addName(naquadahbomb, "Naquadah Bomb");

        RenderingRegistry.registerEntityRenderingHandler(Naquadah_EntityBombPrimed.class, new Naquadah_RenderBomb());

        GameRegistry.addRecipe(new ItemStack(Reinforced_blocks.naquadahbomb), new Object[]

{

    "XIX", "IXI", "XIX", 'X', Reinforced_blocks.naquadahingot, 'I', Item.gunpowder

});

 

Posted

from my mod file

 

naquadahbomb = new Naquadabomb(402,2).setStepSound(Block.soundPowderFootstep).setHardness(3F).setResistance(1.0F).setBlockName("Naquadah Bomb");

      GameRegistry.registerBlock(naquadahbomb);

      LanguageRegistry.addName(naquadahbomb, "Naquadah Bomb");

        RenderingRegistry.registerEntityRenderingHandler(Naquadah_EntityBombPrimed.class, new Naquadah_RenderBomb());

        GameRegistry.addRecipe(new ItemStack(Reinforced_blocks.naquadahbomb), new Object[]

            {

            "XXX", "XXX", "XXX", 'X', Reinforced_blocks.naquadahingot, 'I', Item.gunpowder

            });

 

Render file

 

package reinforced.common;

 

import org.lwjgl.opengl.GL11;

 

import net.minecraft.src.Block;

import net.minecraft.src.Entity;

import net.minecraft.src.Render;

import net.minecraft.src.RenderBlocks;

 

public class Naquadah_RenderBomb extends Render

{

    private RenderBlocks blockRenderer = new RenderBlocks();

 

    public Naquadah_RenderBomb()

    {

        this.shadowSize = 0.5F;

    }

    public void func_76992_a(Naquadah_EntityBombPrimed par1EntityTNTPrimed, double par2, double par4, double par6, float par8, float par9)

        {

            GL11.glPushMatrix();

            GL11.glTranslatef((float)par2, (float)par4, (float)par6);

            float var10;

 

            if ((float)par1EntityTNTPrimed.fuse - par9 + 1.0F < 10.0F)

            {

                var10 = 1.0F - ((float)par1EntityTNTPrimed.fuse - par9 + 1.0F) / 10.0F;

 

                if (var10 < 0.0F)

                {

                    var10 = 0.0F;

                }

 

                if (var10 > 1.0F)

                {

                    var10 = 1.0F;

                }

 

                var10 *= var10;

                var10 *= var10;

                float var11 = 1.0F + var10 * 0.3F;

                GL11.glScalef(var11, var11, var11);

            }

 

            var10 = (1.0F - ((float)par1EntityTNTPrimed.fuse - par9 + 1.0F) / 100.0F) * 0.8F;

            this.loadTexture("/Thormod/blocks.png");

            this.blockRenderer.renderBlockAsItem(Block.tnt, 0, par1EntityTNTPrimed.getBrightness(par9));

 

            if (par1EntityTNTPrimed.fuse / 5 % 2 == 0)

            {

                GL11.glDisable(GL11.GL_TEXTURE_2D);

                GL11.glDisable(GL11.GL_LIGHTING);

                GL11.glEnable(GL11.GL_BLEND);

                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA);

                GL11.glColor4f(1.0F, 1.0F, 1.0F, var10);

                this.blockRenderer.renderBlockAsItem(Block.tnt, 0, 1.0F);

                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

                GL11.glDisable(GL11.GL_BLEND);

                GL11.glEnable(GL11.GL_LIGHTING);

                GL11.glEnable(GL11.GL_TEXTURE_2D);

            }

 

            GL11.glPopMatrix();

        }

        public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)

        {

            this.func_76992_a((Naquadah_EntityBombPrimed)par1Entity, par2, par4, par6, par8, par9);

        }

}

 

 

Entity file

 

package reinforced.common;

 

import net.minecraft.src.Entity;

import net.minecraft.src.NBTTagCompound;

import net.minecraft.src.World;

import cpw.mods.fml.client.registry.RenderingRegistry;

import cpw.mods.fml.common.Side;

import cpw.mods.fml.common.asm.SideOnly;

 

public class Naquadah_EntityBombPrimed extends Entity

{

 

    public int fuse;

 

    public Naquadah_EntityBombPrimed(World par1World)

    {

        super(par1World);

        this.fuse = 0;

        this.preventEntitySpawning = true;

        this.setSize(0.98F, 0.98F);

        this.yOffset = this.height / 2.0F;

    }

    public Naquadah_EntityBombPrimed(World par1World, double par2, double par4, double par6)

    {

        this(par1World);

        this.setPosition(par2, par4, par6);

        float var8 = (float)(Math.random() * Math.PI * 2.0D);

        this.motionX = (double)(-((float)Math.sin((double)var8)) * .02F);

        this.motionY = 0.20000000298023224D;

        this.motionZ = (double)(-((float)Math.cos((double)var8)) * .02F);

        this.fuse = 80;

        this.prevPosX = par2;

        this.prevPosY = par4;

        this.prevPosZ = par6;

    }

    protected boolean canTriggerWalking()

    {

        return false;

    }

    public boolean canBeCollidedWith()

    {

        return !this.isDead;

    }

    public void onUpdate()

    {

        this.prevPosX = this.posX;

        this.prevPosY = this.posY;

        this.prevPosZ = this.posZ;

        this.motionY -= 0.03999999910593033D;

        this.moveEntity(this.motionX, this.motionY, this.motionZ);

        this.motionX *= 0.9800000190734863D;

        this.motionY *= 0.9800000190734863D;

        this.motionZ *= 0.9800000190734863D;

 

        if (this.onGround)

        {

            this.motionX *= 0.699999988079071D;

            this.motionZ *= 0.699999988079071D;

            this.motionY *= -0.5D;

        }

 

        if (this.fuse-- <= 0)

        {

            this.setDead();

 

            if (!this.worldObj.isRemote)

            {

                this.explode();

            }

        }

        else

        {

            this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);

        }

    }

    private void explode()

    {

        float var1 = 20.0F;

        this.worldObj.createExplosion((Entity)null, this.posX, this.posY, this.posZ, var1);

    }

    protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)

    {

        par1NBTTagCompound.setByte("Fuse", (byte)this.fuse);

    }

    protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)

    {

        this.fuse = par1NBTTagCompound.getByte("Fuse");

    }

 

    @SideOnly(Side.CLIENT)

    public float getShadowSize()

    {

        return 0.0F;

    }

    @Override

    protected void entityInit() {

        // TODO Auto-generated method stub

       

    }

}

 

 

Block file

 

package reinforced.common;

 

import java.util.Random;

 

import net.minecraft.src.Block;

import net.minecraft.src.EntityPlayer;

import net.minecraft.src.ItemStack;

import net.minecraft.src.Material;

import net.minecraft.src.CreativeTabs;

import net.minecraft.src.World;

 

public class Naquadabomb extends Block

{

 

    public Naquadabomb(int par1, int par2) {

        super(par1,par2,Material.rock);

        this.setCreativeTab(CreativeTabs.tabBlock);

        // TODO Auto-generated constructor stub

    }

    public int getBlockTextureFromSide(int i)

    {

        if(i == 1 || i == 0)

        {

            return 3;

        }

        else

        {

            return 2;

        }

    }

    public String getTextureFile()

    {

            return "/mod_texture.png";

    }

    public void onBlockAdded(World par1World, int par2, int par3, int par4)

    {

        super.onBlockAdded(par1World, par2, par3, par4);

 

        if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))

        {

            this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);

            par1World.setBlockWithNotify(par2, par3, par4, 0);

        }

    }

    public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)

    {

        if (par5 > 0 && Block.blocksList[par5].canProvidePower() && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))

        {

            this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);

            par1World.setBlockWithNotify(par2, par3, par4, 0);

        }

    }

    public int quantityDropped(Random par1Random)

    {

        return 1;

    }

    public void onBlockDestroyedByExplosion(World par1World, int par2, int par3, int par4)

    {

        if (!par1World.isRemote)

        {

            Naquadah_EntityBombPrimed var5 = new Naquadah_EntityBombPrimed(par1World, (double)((float)par2 + 0.5F), (double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F));

            var5.fuse = par1World.rand.nextInt(var5.fuse / 4) + var5.fuse / 8;

            par1World.spawnEntityInWorld(var5);

        }

    }

    public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5)

    {

        if (!par1World.isRemote)

        {

            if ((par5 & 1) == 1)

            {

                Naquadah_EntityBombPrimed var6 = new Naquadah_EntityBombPrimed(par1World, (double)((float)par2 + 0.5F), (double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F));

                par1World.spawnEntityInWorld(var6);

                par1World.playSoundAtEntity(var6, "random.fuse", 1.0F, 1.0F);

            }

        }

    }

    public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)

    {

        if (par5EntityPlayer.getCurrentEquippedItem() != null && par5EntityPlayer.getCurrentEquippedItem().itemID == Reinforced_blocks.naquadahbomb.blockID)

        {

            this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);

            par1World.setBlockWithNotify(par2, par3, par4, 0);

            return true;

        }

        else

        {

            return super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);

        }

    }

    protected ItemStack createStackedBlock(int par1)

    {

        return null;

    }

   

   

}

 

 

Crash File

 

 

 

      Minecraft has crashed!     

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

 

Minecraft has stopped running because it encountered a problem; Failed to start game

This error has been saved to G:\mcp72\jars\.\crash-reports\crash-2012-08-26_16.20.06-client.txt for your convenience. Please include a copy of this file if you report this crash to anyone.

 

 

 

--- BEGIN ERROR REPORT 7002fbd5 --------

Generated 8/26/12 4:20 PM

 

- Minecraft Version: 1.3.2

- Operating System: Windows 7 (amd64) version 6.1

- Java Version: 1.7.0_05, Oracle Corporation

- Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

- Memory: 799263448 bytes (762 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)

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

- LWJGL: 2.4.2

- OpenGL: AMD Radeon HD 6450 GL version 4.2.11733 Compatibility Profile Context, ATI Technologies Inc.

- Is Modded: Definitely; 'forge,fml'

- Type: Client

- Texture Pack: Default

- Profiler Position: N/A (disabled)

 

cpw.mods.fml.common.LoaderException: java.lang.reflect.InvocationTargetException

    at cpw.mods.fml.common.LoadController.transition(LoadController.java:106)

    at cpw.mods.fml.common.Loader.initializeMods(Loader.java:603)

    at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:217)

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

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

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

Caused by: java.lang.reflect.InvocationTargetException

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

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

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

    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)

    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)

    at com.google.common.eventbus.EventBus.post(EventBus.java:268)

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

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

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

    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)

    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)

    at com.google.common.eventbus.EventBus.post(EventBus.java:268)

    at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:85)

    at cpw.mods.fml.common.Loader.initializeMods(Loader.java:602)

    ... 4 more

Caused by: java.lang.NullPointerException

    at net.minecraft.src.CraftingManager.addRecipe(CraftingManager.java:189)

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

    at reinforced.common.Reinforced_blocks.load(Reinforced_blocks.java:52)

    ... 30 more

--- END ERROR REPORT 6bd33fcd ----------

 

 

 

 

Posted

Either "Reinforced_blocks" or "Reinforced_blocks.naquadahbomb.naquadahbomb" is null. Put a breakpoint right before you add the recipe and see if either one is null.

Couldn't have said it better myself!

Wait... You can add breakpoints with eclipse?

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Posted

Wait... You can add breakpoints with eclipse?

 

I don't know if you are being serious or not, but if you are, click on the line you want to add a breakpoint on and press ctrl+shift+B

 

I added a break point at line 52 (the start of my recipe) and the error was the same :P

 

Breakpoints don't solve the problem, they let you stop the code and look at what values the variables have, check to see what the variables are before the function then if you have to do a "step in to" do go inside the function and find where the null is happening. Also please include your entire main mod file, not just those 4 lines of code.

Posted

 

 

and in debug under varibles are :

 

Name                                            Value

  this                                                Reinforced_blocks(id=54)

  event                                            FMLInitializationEvent (id=55)

Posted

 

and in debug under varibles are :

 

Name                                            Value

  this                                                Reinforced_blocks(id=54)

  event                                            FMLInitializationEvent (id=55)

 

Just so you know, for the future, hit the + next to "this" ("this" represents the class you currently are stopped inside) You would see something like.

 

Name                                            Value
  this                                          Reinforced_blocks(id=54)
      naquadahbomb                              naquadhbomb(id=123)
      naquadahingot                             null
  event                                         FMLInitializationEvent (id=55)

That would have told you that naquadahingot was null and you where trying to use it. If what you want are not inside "this" or one of the automatic variaibles you can add a variable to the "watch list" forces the item to be in the list. You do this by highlighting the variable you want, right click, then click "watch".

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.