Jump to content

Check In a Radius Around the Player


Recommended Posts

I was wondering how I could check for a radius around the player, so that I can sort any living entities into a list? The concept is I want any living entities that come in a specific radius of the player to be set on fire.

Link to comment
Share on other sites

Get the player's bounding box, make it bigger (grow, expand), and there are a couple methods in World called getEntitiesWithinAABB or something similar where returns a collection of entities that meets the conditions.

If you want it to be more accurate (bounding box is a cube), you can also check the distance between two entities by Vector3d#distanceTo.

Link to comment
Share on other sites

Ok, so I did find this method called getNearbyEntities and started playing around with it, but I'm having trouble figuring out what to put in the place of some of these parameters

getNearbyEntities(Class<? extends T> p_217374_1_, EntityPredicate p_217374_2_, LivingEntity p_217374_3_, AxisAlignedBB p_217374_4_)

I had already gotten that AxisAlignedBB is just the bounding box aka the radius to check and I just assume EntityPredicate could just be the default, but the other two I'm unsure about if anyone could explain?

Link to comment
Share on other sites

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.

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

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