getNearbyEntities

Discussion in 'Plugin Development' started by Oliveirah, May 25, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    Oliveirah

    Could someone help-me please? I Got that problem with the NearbyEntities and i really dont know how to solve it

    public boolean near(Location l) {
    for (Entity entity : l.getWorld().getNearbyEntities(l, 9, 5, 9)){
    if (entity instanceof Player)
    return true;
    }
    return false;
    }

    The error appears on "getNearbyEntities" and shows :
    The method getNearbyEntities(Location, int, int, int) is undefined for the type World

    If you wanna see all the code, here we go : https://pastebin.com/51TqU6zP
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    Oliveirah

    @timtower
    Hello sr, thanks by the answer, i changed it to :

    public boolean near(Location l) {
    double a = 9;
    double b = 5;
    double c = 9;
    for (Entity entity : l.getWorld().getNearbyEntities(l, a, b, c)){
    if (entity instanceof Player)
    return true;
    }
    return false;
    }

    but it stills not working, appears the same error :
    • The method getNearbyEntities(Location, double, double, double) is undefined for the type World
    Pastebin CODE : https://pastebin.com/DqNKD3zD
     
  4. Offline

    timtower Administrator Administrator Moderator

    @Oliveirah What minecraft version are you on?
     
  5. Offline

    Oliveirah

    Hello mr @timtower, sorry to take too many time to reply it again, so ...
    I am using "spigot-1.8.8-R0.1-SNAPSHOT-latest"
     
  6. Offline

    timtower Administrator Administrator Moderator

    That might be the reason why you don't have that method.
    Try looping over the players and doing distance checks.
     
  7. Offline

    KarimAKL

    @timtower World#getNearbyEntities(Location, double, double, double) seems to have been added in version 1.8.3.

    @Oliveirah Are you sure that you're building & running 1.8.8?
     
Thread Status:
Not open for further replies.

Share This Page