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 was wondering if there was a function similar to world.getClosestPlayer. I need it something I can iterate through with a for loop. I'm basically trying to heal any player close but hurt any hostile mob close.

Bumper Cars!

  • Author

So i've tried this:

 

		for(CoordEntry entry: connectedNodes)
	{
		double bnX = baseNodePos.getX();
		double bnY = baseNodePos.getY();
		double bnZ = baseNodePos.getZ();
		double eX = entry.getPos().getX();
		double eY = entry.getPos().getY();
		double eZ = entry.getPos().getZ();

		List entities = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(eX, eY, eZ, bnX, bnY, bnZ));
		if(player != null) player.addChatMessage(new ChatComponentText("Entities: " + entities.size()));
	}

 

but my chat message always says "Entities: 0" even when I'm in range. Fyi the baseNode position and entry position are on the same X axis but have different Z coordinates

 

is there a better way to debug the bounding box that this.worldObj.getEntitiesWithinAABB creates? I think that would help solve my problem

Bumper Cars!

is there a better way to debug the bounding box that this.worldObj.getEntitiesWithinAABB creates? I think that would help solve my problem

 

I usually put in console or logger statements such as System.out.println() and print out useful info. In this case you could print out the bounds of the bounding box and see it if makes sense considering where it is supposed to be in the world you're playing in.

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

                    for (EntityLivingBase e:world.getEntities(EntityLivingBase.class, new Predicate<EntityLivingBase>() {

                        @Override
                        public boolean apply(EntityLivingBase input) {
                            return (input.getDistanceToEntity(player) <= DISTANCE);
                        }
                    })) {
                        // Do stuff
                    }

 

It's not super clean or elegant, but it does work.

Just make sure you get the right imports.

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.