Entity setHealth?

Discussion in 'Plugin Development' started by Prophettt, Dec 17, 2013.

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

    Prophettt

    Hi,

    I'm a little noob at Coding trying to learn and after looking I've seen no easy solution to this.
    I want a Zombie to for example only have 1 health instead of twenty, to then be able to add more features to after the Zombie dies.

    But how do I change the Zombie's Health?
     
  2. Offline

    EcMiner

    What you could do is check in CreatureSpawnEvent if the entity is zombie and if it is set his health to 1. Then you check in EntityDeathEvent if the entity who died is a zombie do something
     
  3. Offline

    DrMedia

    Expanding on EcMiner, here's a little example.

    Code:
    @EventHandler
          public void CreatureSpawnEvent(CreatureSpawnEvent event){
            if(event.getEntity() instanceof Zombie){
                event.getEntity().setHealth(/* When you say 1, do you mean 1 heart or half? /* 1);
            }
        }
    @EventHandler
          public void EntityDeathEvent(EntityDeathEvent event){
            if(event.getEntity() instanceof Zombie){
                event.setCancelled(true);
                event.getEntity().setCustomName("Hi, I'm dead!");
                event.getEntity().setCustomNameVisable(true);
            }
        }
    
     
  4. Offline

    EcMiner

    Didn't bukkit remove entity.setHealth() since the 1.6 update? Correct me if i'm wrong :p
     
  5. Offline

    DrMedia

  6. Offline

    EcMiner

    But isn't it ambiguous?
     
  7. Offline

    DrMedia

  8. Offline

    EcMiner

    Nice! They probably changed it in the new bukkit 1.7 api cause i can remember that in 1.6 i had to cast entities to Damageable
     
Thread Status:
Not open for further replies.

Share This Page