Damaging entities in radius

Discussion in 'Plugin Development' started by ItsMas_, Feb 2, 2016.

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

    ItsMas_

    I am making a "Ground Pound" ability, and here is my code:
    Code:
        @EventHandler
        public void onDamage(EntityDamageEvent d){
            if (d.getEntity() instanceof Player){
                Player faller = (Player) d.getEntity();
                if (d.getCause() == DamageCause.FALL){
                    if (pounding.contains(faller.getName())){
    
                        pounding.remove(faller.getName());
                        d.setCancelled(true);
    
                        List<Entity> nearby =  ((Entity) d).getNearbyEntities(5,5,5);
                        for (Entity tmp: nearby)
                            if (tmp instanceof Damageable)
                                ((Damageable) tmp).damage(5);
    
                    }
                }
            }
        }
    When I use the abiltiy and hit the ground, I am supposed to deal 5 damage to all entities in a radius of 5 blocks. For some reason this isn't working.

    There are no errors anywhere.

    What have I forgotten to add?
     
  2. Offline

    WinX64

    You're casting the EntityDamageEvent to an Entity.
    I think what you probably meant, was to get the damaged entity and get the entities near by.
    Code:
    d.getEntity()
     
Thread Status:
Not open for further replies.

Share This Page