Posted July 8, 201510 yr I'm trying to make an item that affects entities within a radius around the player using World#getEntitiesWithinAABB and AxisAlignedBB#expand, but the game crashes whenever I try to create the List<EntityLiving> of entities to affect. Here's the crash log: [16:18:18] [Client thread/FATAL]: Reported exception thrown! [16:32:44] [Client thread/FATAL]: Reported exception thrown! net.minecraft.util.ReportedException: Ticking entity at net.minecraft.world.World.updateEntities(World.java:1837) ~[World.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:2176) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1080) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_45] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] Caused by: java.lang.NullPointerException at com.ferret.myfirstmod.items.ItemIceMask.onArmorTick(ItemIceMask.java:85) ~[itemIceMask.class:?] at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:358) ~[inventoryPlayer.class:?] at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:623) ~[EntityPlayer.class:?] at net.minecraft.client.entity.EntityPlayerSP.onLivingUpdate(EntityPlayerSP.java:913) ~[EntityPlayerSP.class:?] at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1828) ~[EntityLivingBase.class:?] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:334) ~[EntityPlayer.class:?] at net.minecraft.client.entity.EntityPlayerSP.onUpdate(EntityPlayerSP.java:165) ~[EntityPlayerSP.class:?] at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2031) ~[World.class:?] at net.minecraft.world.World.updateEntity(World.java:1997) ~[World.class:?] at net.minecraft.world.World.updateEntities(World.java:1823) ~[World.class:?] ... 12 more And the method in question: public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { if(KeyBindings.ability.isPressed()) { if(!world.getEntitiesWithinAABB(EntityLiving.class, player.getBoundingBox().expand(10, 10, 10)).isEmpty()) // the problematic line { List<EntityLiving> entities = world.getEntitiesWithinAABB(EntityLiving.class, player.getBoundingBox().expand(10, 10, 10)); for(EntityLiving entity : entities) { if(!entity.equals(player)) { entity.addPotionEffect(new PotionEffect(2, 2000, 99)); } } } } }
July 8, 201510 yr You do not handle a case where Minecraft cannot find any entities. What is on this line? at com.ferret.myfirstmod.items.ItemIceMask.onArmorTick(ItemIceMask.java:86) EDIT: Woops, i'm blind. I see it.
July 8, 201510 yr Author I tried that, no luck. I've also updated the crash log and code accordingly. It's crashing whenever I even ask about the bounding box (it crashes on the if statement).
July 9, 201510 yr That's because, contrary to all expectation, Entity#getBoundingBox returns NULL. Don't use it. Instead, use Entity#getEntityBoundingBox, which actually returns the entity's bounding box. http://i.imgur.com/NdrFdld.png[/img]
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.