poison a entity

Discussion in 'Plugin Development' started by spacemoehre, Oct 19, 2014.

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

    spacemoehre

    Is it possible to poison or ignit an entity? and how?
     
  2. Offline

    TheCodingCat

    easy spacemoehre <entity>.addPotionEffect(YourPotionEffect);
     
  3. Offline

    spacemoehre

    TheCodingCat in my EntityDamageEntityEvent, is this not availeble for e.getDanager()....
     
  4. Offline

    FerusGrim

    Code:java
    1. public void poisonEntity(LivingEntity entity) {
    2. if (!entity.addPotionEffect(PotionEffect.POISON) && entity instanceof Player)) {
    3. ((Player) entity).sendMessage("You couldn't be poisoned!");
    4. }
    5. }


    or

    Code:java
    1. public void igniteEntity(Entity entity) {
    2. entity.setFireTicks(600); // 30 seconds
    3. }
     
  5. Offline

    TheCodingCat

    then do
    e.getEntity().getLastDamager()
     
  6. Offline

    FerusGrim

    spacemoehre

    You mean EntityDamageByEntityEvent?

    EntityDamageByEntityEvent#getDamager returns an Entity. However, you cannot add potion effects to entities. Check if the Entity is an instance of a LivingEntity. If it is, cast it, then add the potion effect.
     
  7. Offline

    spacemoehre

    FerusGrim tried it but PotionEffect.POISON cannot be resolved (just copied your method)

    TheCodingCat e.getEntity().getLastDamager() does not exists

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  8. Offline

    FerusGrim

    Sorry, try:
    Code:java
    1.  
    2. addPotionEffect(new PotionEffect(PotionEffectType.POISON, 40, 1));
     
  9. Offline

    TheCodingCat

    sorry my bad. I'm on stupid phone Use
    if (e.getLastDamageCause().equals(DamageCause.ENTITY_ATTACK))
    then get last damager
     
  10. Offline

    spacemoehre

    FerusGrim what are these numbers used for?
     
  11. Offline

    FerusGrim

    I refuse to answer a question like this when a single glance at the JavaDocs will answer it for you.
     
Thread Status:
Not open for further replies.

Share This Page