On Wither Skull hit add effects to player

Discussion in 'Plugin Development' started by thapengwin, May 14, 2013.

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

    thapengwin

    I'm having quite a problem here (Which you can probably solve in a few seconds... What can I do, I'm a noob) - I want to add a wither effect to a player on wither skull hit. I know that the player gets the effect when a Wither hits you with it's skull, but I've made a "Wither Skull Bow" and it just doesn't give the effects. My code so far:
    Code:
    public void skullHit(EntityDamageByEntityEvent e) {
          Player victim = (Player) e.getEntity();
          if(victim instanceof Player) {
          if(e.getDamager() instanceof WitherSkull) {
            victim.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 0, 10));
            }
          }
        }
     
  2. Offline

    thecrystalflame

    new PotionEffect(PotionEffectType.WITHER, DURATION!, MODIFIER)
    try changing it to this.
    Code:
    public void skullHit(EntityDamageByEntityEvent e) {
    if(e.getEntity() instanceof Player) { //needed
    Player victim = (Player) e.getEntity();
    if(e.getDamager() instanceof WitherSkull) {
    victim.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 10, 1));
    }
    }
    }
    you had the duration of the potion effect set to zero meaning the effect wont occur.
    your modifier was also set to 10 meaning the effects would be ultimate.
     
Thread Status:
Not open for further replies.

Share This Page