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

I want my custom wagon entity to add an instance of EntityAnimal and add it to a field like an array or list for my custom entity and have the passive entity move while the wagon is moving. When getEntitiesWithinAABB is called, it's not returning any entities in the list, I am fairly new to entity processing. I am using similar code found in the method interactFirst of the EntityLeashKnot class. Here is the source code:

/**
* First layer of player interaction
*/
public boolean interactFirst(EntityPlayer playerEntity)
{
double minMaxAABB = 7.0D;

// Get list of all entities leashed by player
List leashedList = this.worldObj.getEntitiesWithinAABB(
EntityAnimal.class,
AxisAlignedBB.getBoundingBox((double) this.posX - minMaxAABB, (double) this.posY
- minMaxAABB, (double) this.posZ - minMaxAABB, (double) this.posX
- minMaxAABB, (double) this.posY + minMaxAABB, (double) this.posZ
+ minMaxAABB));

// if there are up to 2 entities leashed anchor them to the wagon
if (leashedList != null && leashedList.size() <= 2)
{
	System.out.println("Returned list of leashed entities on interaction with wagon entity");
	Iterator iterator = leashedList.iterator();

	while (iterator.hasNext())
	{
		EntityAnimal entity = (EntityAnimal) iterator.next();

		if (entity.getLeashed() && entity.getLeashedToEntity() == playerEntity)
		{
			// break leash from player
			entity.clearLeashed(true, true);

			// add entity to wagon
			this.entityHorses.add(entity);

			// DEBUG: to know the correct entities are referenced
			System.out.println(this.entityHorses.isEmpty());
		}
	}

}
return true;
}

You made a typo in your bounding box:

AxisAlignedBB.getBoundingBox((double) this.posX - minMaxAABB, (double) this.posY

- minMaxAABB, (double) this.posZ - minMaxAABB, (double) this.posX

- minMaxAABB, (double) this.posY + minMaxAABB, (double) this.posZ

+ minMaxAABB));

 

The second posX should be +minMaxAABB not -minMaxAABB.

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.