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.

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

Featured Replies

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?

  • Author
3 hours ago, Luis_ST said:

you need a EntityPredicate and not a Functionย 

How can I do that?

  • Author
7 hours ago, diesieben07 said:

Incorrect.

Look at the parameters of getNearbyEntities. There is no predicate parameter. You can pass one indirectly using the TargetingConditions parameter.

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

https://imgur.com/a/50EZf6l

  • Author
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);

ย 

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)
  • Author
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...

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.