Posted April 3, 20169 yr I'm trying to make a creeper-like mob (it extends EntityCreeper) that explodes and then burns all mobs in an x-block radius. The explosion works fine but the burning code (specifically the part that gets all mobs in the radius) is giving me an NPE "exception ticking entity". Is there a better way to do this? Code below: List<EntityLiving> theList = this.worldObj.getEntitiesWithinAABB(EntityLiving.class, this.getBoundingBox().expand(eR, eR, eR));. //This line is the code referenced during the crash report for(EntityLiving entity: theList) { if(entity != null) { entity.setFire(; } }
April 3, 20169 yr It's always best to post the crash log, but my guess is this is the cause of your crash: this.getBoundingBox() For some strange reason, it usually returns null. Use #getEntityBoundingBox instead, as that will return the actual bounding box. http://i.imgur.com/NdrFdld.png[/img]
April 4, 20169 yr First, you should articulate your code (assign each method result to a local variable before passing vars to the next method). Then set a break point and fire up the debugger to step through the articulated code, looking at values at each line. Find out exactly what is null. If you discover why it is null, then you don't even need our help. If not, then you can ask a better-informed question. The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.
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.