Damage Entities in BlockIterator.

Discussion in 'Plugin Development' started by zDubsCrazy, Sep 7, 2014.

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

    zDubsCrazy

    This code make a 'HADOUKEN':
    Code:java
    1. BlockIterator blocks = new BlockIterator(location, 0.0, 40);
    2. Location block;
    3. while(blocks.hasNext()) {
    4. block = blocks.next().getLocation();
    5. Effect a = Effect.STEP_SOUND;
    6. p.getWorld().playEffect(block, a, Material.BEACON, 20);
    7. }

    I want to cause damage to all entities that are within, or even at the finish of this line.

    Thanks in advance.
     
  2. Offline

    IkBenHarm

    zDubsCrazy
    i do it like this
    Code:java
    1. Location location = player.getEyeLocation();
    2. BlockIterator blocksToAdd = new BlockIterator(location, 0D, 20);
    3. Location blockToAdd;
    4.  
    5. while(blocksToAdd.hasNext()) {
    6.  
    7. blockToAdd = blocksToAdd.next().getLocation();
    8. player.getWorld().playEffect(blockToAdd, Effect.POTION_BREAK, 2);
    9.  
    10. double radius = 1.5D;
    11. List<Entity> near = location.getWorld().getEntities();
    12.  
    13. for(Entity e : near) {
    14. if(e.getLocation().distance(blockToAdd) <= radius && e != player){



    and then check if e is Damageable or Player or something and damage
     
    zDubsCrazy likes this.
  3. Offline

    zDubsCrazy

Thread Status:
Not open for further replies.

Share This Page