Jump to content

I have a problem finding entitties in a five block radius around the player [1.17]


Recommended Posts

Posted

It's a short line I am having an issue with:

                        List<LivingEntity> entities = player.getLevel().getNearbyEntities(LivingEntity.class,
                                player.getBoundingBox().inflate(5,0,5), LivingEntity::isAlive);

On the LivingEntity::isAlive part where it says "is not a functional interface"

Any suggestions?

Posted
9 minutes ago, diesieben07 said:

 

I am deeply sorry and apologize, my java knowledge isn't the best but sometimes simple stuff like these confuse me but can do other complex stuff,

I've put this and pretty sure this is wrong as well, could you maybe please show me the correct way

                        List<LivingEntity> entities = player.getLevel().getNearbyEntities(LivingEntity.class,
                                TargetingConditions.DEFAULT,
                                player.getBoundingBox().inflate(5,0,5), LivingEntity::isAlive);

 

Posted
7 hours ago, diesieben07 said:

Incorrect.

Look at the parameters of getNearbyEntities. There is no predicate parameter.

it was the 1.16.5 name for TargetingConditions

16 minutes ago, Feroov said:

I'm still a bit lost, here is a picture just in case:

I'm not sure which method you use, since there is only one method in Level with the name getNearbyEntities and it requires 4 parameters:

getNearbyEntities(Class<T>, TargetingConditions, LivingEntity, AABB)

and not

getNearbyEntities(Class<T>, AABB, TargetingConditions)
Posted
7 minutes ago, Luis_ST said:

it was the 1.16.5 name for TargetingConditions

I'm not sure which method you use, since there is only one method in Level with the name getNearbyEntities and it requires 4 parameters:

getNearbyEntities(Class<T>, TargetingConditions, LivingEntity, AABB)

and not

getNearbyEntities(Class<T>, AABB, TargetingConditions)

Yes it worked now, thank you so so much for all who helped appreciate it

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...

×   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.

Announcements



×
×
  • Create New...

Important Information

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