Jump to content

Recommended Posts

Posted

Ok, so my ammo crashes the game when it hits an entity, but if it just hits a block, it explodes, with no issues. Here is the crash report:

 

  Reveal hidden contents

 

And my entity code:

 

  Reveal hidden contents

 

Anyone know how to fix the issue? Any help is appreciated.

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Posted

Superclass:

 

  Reveal hidden contents

 

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Posted

Exactly what line the NPE got out?

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted
  On 5/11/2015 at 3:48 AM, The_Fireplace said:

  Quote

Exactly what line the NPE got out?

As in, the line it is pointing to in the crash report?

this.worldObj.createExplosion(this, mop.getBlockPos().getX(), mop.getBlockPos().getY(), mop.getBlockPos().getZ(), 1.5F, true);

So only two possibilities are: worldObj is null(impossible), or mop.getBlockPos() is null(also impossible)

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted
  On 5/11/2015 at 3:53 AM, Abastro said:

  Quote

  Quote

Exactly what line the NPE got out?

As in, the line it is pointing to in the crash report?

this.worldObj.createExplosion(this, mop.getBlockPos().getX(), mop.getBlockPos().getY(), mop.getBlockPos().getZ(), 1.5F, true);

So only two possibilities are: worldObj is null(impossible), or mop.getBlockPos() is null(also impossible)

Yeah, that is why I was stumped, too. Perhaps it will help figure it out that the following file for 1.7.10 worked. https://bitbucket.org/The_Fireplace/devons-random-things/src/f24522e68bb28fd2b065836a9f564eaf30e9dbc1/src/main/java/the_fireplace/devonmod/entities/EntityChargedCoal.java?at=master

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Posted
  On 5/11/2015 at 4:01 AM, The_Fireplace said:

  Quote

  Quote

  Quote

Exactly what line the NPE got out?

As in, the line it is pointing to in the crash report?

this.worldObj.createExplosion(this, mop.getBlockPos().getX(), mop.getBlockPos().getY(), mop.getBlockPos().getZ(), 1.5F, true);

So only two possibilities are: worldObj is null(impossible), or mop.getBlockPos() is null(also impossible)

Yeah, that is why I was stumped, too. Perhaps it will help figure it out that the following file for 1.7.10 worked. https://bitbucket.org/The_Fireplace/devons-random-things/src/f24522e68bb28fd2b065836a9f564eaf30e9dbc1/src/main/java/the_fireplace/devonmod/entities/EntityChargedCoal.java?at=master

Then.. Try debugging to find exactly what is null.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted
  On 5/11/2015 at 4:12 AM, Abastro said:

  Quote

  Quote

  Quote

  Quote

Exactly what line the NPE got out?

As in, the line it is pointing to in the crash report?

this.worldObj.createExplosion(this, mop.getBlockPos().getX(), mop.getBlockPos().getY(), mop.getBlockPos().getZ(), 1.5F, true);

So only two possibilities are: worldObj is null(impossible), or mop.getBlockPos() is null(also impossible)

Yeah, that is why I was stumped, too. Perhaps it will help figure it out that the following file for 1.7.10 worked. https://bitbucket.org/The_Fireplace/devons-random-things/src/f24522e68bb28fd2b065836a9f564eaf30e9dbc1/src/main/java/the_fireplace/devonmod/entities/EntityChargedCoal.java?at=master

Then.. Try debugging to find exactly what is null.

The crash tells you what is null! It is a NPE Ticking Entity. So the entity is null, try killing the entity after you create the explosion.

Posted
  On 5/11/2015 at 4:45 AM, saxon564 said:

The crash tells you what is null! It is a NPE Ticking Entity. So the entity is null, try killing the entity after you create the explosion.

That is just a tag on the Crash when mc crashed while updating(ticking) an entity.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted
  On 5/11/2015 at 4:53 AM, saxon564 said:

my experience while working with entities is that when you get an NPE with Ticking Entity, usually it is your entity that is null.

Oh, I didn't know that can throw NPE while ticking entity.;

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

With how I've found ticking to work, adding a method to the list of things to do seems to tick an extra time. Could just be some faulty testing, but if that is the case, then when it ticks the entity for a worldObj, it will return null because it cant find the entity so the worldObj would also be null. So even if it is talking about worldObj, it is only null because the entity is null. and because the entity is null and causing the NPE to throw, it tags Ticking Entity, if the BlockPos was null, but the entity wasnt, it should say something else. Now if I'm wrong, I'm sure one of the forum moderators will correct me, but I am speaking from all the NPEs I've has with the Ticking Entity tag.

Posted
  On 5/11/2015 at 5:20 AM, saxon564 said:

With how I've found ticking to work, adding a method to the list of things to do seems to tick an extra time. Could just be some faulty testing, but if that is the case, then when it ticks the entity for a worldObj, it will return null because it cant find the entity so the worldObj would also be null. So even if it is talking about worldObj, it is only null because the entity is null. and because the entity is null and causing the NPE to throw, it tags Ticking Entity, if the BlockPos was null, but the entity wasnt, it should say something else. Now if I'm wrong, I'm sure one of the forum moderators will correct me, but I am speaking from all the NPEs I've has with the Ticking Entity tag.

Wait, I think you missed point, 'this' cannot be null in any time.

GC only collects the died entity only when it is not running any code.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

I can't tell if what you are doing is bad or just coding style, but know one thing:

When your throwable hits something you still have entity (not yet dead).

 

There is no need to use mop.getBlockPos() to get the x/y/z of hit, you can simply use: this.posX, this.posY, this.posZ

 

That is probably your NPE, blockPos is only when thrown entity hits actual block, for entity it's different.

 

Following code:

onImpact() is called on both server and client.

if (mop.entityHit != null)
{
// Do stuff on entity, use its x/y/z or the direct x/y/z of throwable to make "explosions" in place hit, not the center of entity.
}
else // It's block.

 

EDIT:

The point is - you can't have both blockPos and Entity - mop is either one or the other.

 

I am basing this on code:

if (entity != null) // Entity is the one found by mop inside onUpdate()
{
movingobjectposition = new MovingObjectPosition(entity); // the original mop is overriden with one with entity in constructor
}

This is the mop with entity child-constructor - it has NO BlockPos.

public MovingObjectPosition(Entity p_i45482_1_, Vec3 p_i45482_2_)
{
        this.typeOfHit = MovingObjectPosition.MovingObjectType.ENTITY;
        this.entityHit = p_i45482_1_;
        this.hitVec = p_i45482_2_;
}

I don't know for sure, but code suggest that BlockPos is null when you hit entity :D

  Quote

1.7.10 is no longer supported by forge, you are on your own.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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