Poison Sword

Discussion in 'Plugin Development' started by CoderRevolq, Apr 4, 2014.

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

    CoderRevolq

    How do i make a sword so every time I hit a player , it gives them poison ? I know I can do p.addPotionEffect, But I want the sword to make a splashing effect, like it throws a poison potion at the player, and it effects the player and ONLY the player. So for example if I hit the player instead of p.addPotionEffect, I send a poison potion at them and the poison only affects them, help please!
     
  2. Offline

    MrInspector

    Get the world / players location / whatever and play the effect POTION? (Reason for question mark; I can't fully understand you)
     
  3. Offline

    AoH_Ruthless

    CoderRevolq
    In an EntityByDamageEntityEvent, then get the damaged entity and check if it's instance is a player.

    If so, spawn a splash potion entity on their location and add a poison effect:

    Code:java
    1. @EventHandler
    2. public void onBlah(EntityDamageByEntityEvent e) {
    3. // Check instance
    4. // define players (I'm calling damaged player p)
    5. // Poison for 5 seconds.
    6. p.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 100, 2));
    7. p.getWorld().spawnEntity(p.getLocation(), EntityType.SPLASH_POTION);
    8.  
    9. }
     
Thread Status:
Not open for further replies.

Share This Page