Posted April 13, 201411 yr EDIT: I figured it out, I wasn't getting the AABB correctly and I wasn't positioning it correctly either. Here's a sample for others that may need this in the future. AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 1), (double)(this.zCoord + 1)) You can also use .expand to change this size of your box. Original Message: I'm trying to retrieve a list of entities within a specified area. I've been trying to use a custom AABB with worldObj.getEntitiesWithinAABB(), but I can't seem to get my list to display anything when I send it to the log. I've never used AABB so that's probably my problem. I am attempting to use the following code because of the EntityAILookAtVillager script that makes the Iron Golem look at villagers. It's also repeated in other "AILookAt" scripts. Here's the code I'm tinkering with atm. It's in one of my TileEntity scripts. //Returns list of entities within AABB private List<EntityLiving> getEntityInRange(){ AxisAlignedBB detectionBB = AxisAlignedBB.getBoundingBox(5.0D, 2.0D, 5.0D, 5.0D, 2.0D, 5.0D); detectionBB.offset(xCoord, yCoord, zCoord); List entitylist = worldObj.getEntitiesWithinAABB(EntityLiving.class, detectionBB); if(!entitylist.isEmpty()){ System.out.println("Found entity(ies): " + Arrays.toString(entitylist.toArray())); return entitylist; } System.out.println("NOTHING DETECTED"); return null; } Any help is much appreciated. --Thanks, Navybofus http://i43.tinypic.com/95v5n9.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.