Jump to content

Recommended Posts

Posted

Ok, so I'm working on armor that can detect players within a variable radius(which is set earlier in the void), then interacting with them. Here is my code for it:

 

  Reveal hidden contents

 

Upon equipping a piece of the armor, it crashes, and the report points me to the following line of code:

List players = world.getEntitiesWithinAABB(EntityPlayer.class, player.getBoundingBox().expand(expansionLevel, expansionLevel, expansionLevel));

How do I fix this?

If I helped please press the Thank You button.

 

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

Posted

It crashes but with what error? And also you can use List because it's just a List waiting to be declared, and getEntitiesWithinAABB returns a list of the target type.

 

is the error a null pointer? index out of bounds? cannot cast the list? (like memcallen suggested, and I blindly said no worries) was gonna say the expansionLevel would cause an issue, but I think the only issue is when 2 or more players wear it that value will be flying all over the place. Best to make it a method scope variable, than a class one.

 

Posted

Here is the crash report

 

  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

so what is null?

expansionLevel?

player?

world?

 

what if you make expansion level start at 1? use some System.out.println() for each variable that goes into that line (before it is called) should help you see what is null. if they all check out fine it could be that somewhere that method is returning null or getting something that is null.

Posted
  On 9/30/2014 at 10:56 PM, hugo_the_dwarf said:

so what is null?

expansionLevel?

player?

world?

 

what if you make expansion level start at 1? use some System.out.println() for each variable that goes into that line (before it is called) should help you see what is null. if they all check out fine it could be that somewhere that method is returning null or getting something that is null.

I've done more testing and using System.out.println(""), and expansionLevel isn't being changed like it is supposed to. However, that isn't the issue. I tried replacing the expansionLevel variable in getEntitiesWithinAABB with 3, and it still crashed. Meaning expansionLevel isn't causing it to crash. That leaves player and world. Seeing as player is the player wearing the armor and world is the world the player is in, I doubt either of them are returning null, either.

If I helped please press the Thank You button.

 

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

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.