Solved CreateExplosion - No Block damage?

Discussion in 'Plugin Development' started by Metal Julien, Nov 4, 2012.

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

    Metal Julien

    Hi, I'm writing a grenade plugin. Now, I need to know 2 things:

    1. How can I define, that the explosion doesn't break blocks but hurts zombies?

    2. How can I raise the explosion damage to mobs but not the radius?


    Thaaaanks, Metal_Julien

    Heeulp

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  2. Offline

    mathiasrocker

    I tryed help you
     
  3. if you want more damage, but the same block break radius, try multiple 0.0 F explotions, ar removing al blocks fom the damage list
     
  4. Offline

    fireblast709

    Untested, but should work:
    Code:java
    1. public void grenade(Location l, double radius, int damage)
    2. {
    3. l.getWorld().createExplosion(l, 0.0f, false);
    4. List<Entity> entities = l.getWorld().getEntities();
    5. for(Entity e : entities)
    6. {
    7. if(!(e instanceof LivingEntity))
    8. continue;
    9. Location el = e.getLocation();
    10. double distance = el.distance(l);
    11. if(distance <= radius)
    12. {
    13. int h = ((LivingEntity)el).getHealth() - damage;
    14. ((LivingEntity)el).setHealth(h);
    15. }
    16.  
    17. }
    18. }
     
    blackwolf12333 likes this.
  5. Offline

    Metal Julien

Thread Status:
Not open for further replies.

Share This Page