Fireman kit - Make the fireman immune to firedamage

Discussion in 'Plugin Development' started by Doodledew, Jun 25, 2013.

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

    Doodledew

    Hai there!
    I'm coding a kitserver, and I was planning on coding the Fireman kit!
    When the player choses the fireman kit they will be a part of the fireman arraylist.
    So only the players that is inside the arraylist will be immune to firedamage!
    But if you swim in lava, you will get damaged. Only if you are on fire you won't get hurt.

    Desc:
    - Immune to fire damage
    *blah-blah*

    So, I've heard that you need to cancel the event and so on, since I'm kinda noob, I don't know how to do that. If someone could teach me that, or give me a link so I can learn it, that would be awesome :3
    Thanks!

    - Doodle
     
  2. Offline

    EcMiner

    Code:java
    1. @EventHandler
    2. public void damage(EntityDamageEvent event) {
    3. if (event.getEntity() instanceof Player) {
    4. Player p = (Player) event.getEntity();
    5. if (event.getCause() == DamageCause.FIRE_TICK) {
    6. p.setFireTicks(0);
    7. event.setCancelled(true);
    8. }
    9. }
    10. }


    You should add a check if the player is a fireman, but i think this should work :)
     
  3. Offline

    Doodledew


    The player still took damage by it. And is there any way to remove the damage when you are standing inside a flame?
    It's kind of like: The flame doesn't have to vanish, it's just that the player won't be affected by it ^^

    Thanks!
     
  4. Offline

    foodyling

    Try doing this:
    if (event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE) {
    event.setCancelled(true);
    p.setFireTicks(0);
    }
    I believe both of those types of DamageCause's are called
     
  5. Offline

    Luke_Lax

  6. Offline

    EcMiner


    Yeah, I didn't really know what DamageCause.FIRE was, cause when i tested to only cancel the event if the damagecause was FIRE it would still damage him and set him on fire, i don't really know what it does xD
     
  7. Offline

    foodyling

    Did it work?
     
  8. Offline

    Doodledew

    No D:
     
  9. Offline

    RealDope

    Did you register the events and implement Listener?
     
  10. Offline

    Doodledew

    Yes

    onEnable()
    blah-blah, registerEvents(this, this);

    Listener, implented
     
Thread Status:
Not open for further replies.

Share This Page