Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.