Solved get nearby entities and damage them?

Discussion in 'Plugin Development' started by Vincent1468, Mar 28, 2013.

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

    Vincent1468

    Hello,

    I've got a question, is it possible to get nearby entities in a location and then damage them?

    I've got this to get the block that the player is looking at:
    Code:
    Block block = player.getTargetBlock(null, 50);
    Location location = block.getLocation();
    Now I want to damage the entities in a radius of 3 there.

    I hope someone can tell me how to do this.
    Thanks.
     
  2. Offline

    JazzaG

    Code:
    double radius = 3D;
    List<Entity> near = location.getWorld().getEntities();
    for(Entity e : near) {
        if(e.getLocation().distance(location) <= radius) 
            e.damage(9001);
    }
    
     
  3. Offline

    Ibix13

    ERMAHGRDZ It's over 9000!!!!!!!!!!!
     
  4. Offline

    Vincent1468

    Ibix13
    Why bump this old thread?
     
    JazzaG likes this.
  5. Offline

    Ibix13

    I saw that it was over 9000.... I had too XD
     
Thread Status:
Not open for further replies.

Share This Page