Help me with some things

Discussion in 'Plugin Development' started by Pik0, Apr 19, 2014.

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


    Hi guys i've been coding some minigames, and i was managing some events when i noticed something:

    When i cancel an EntityDamageEvent, if a player gets shot by the arrow, the arrow ricochets and could possibly damage the arrow launcher.

    Other thing is i want to prevent people from destroying soiled dirt. When someone jumps into soiled dirt, it transforms into normal dirt. How can i prevent this
  2. Offline


  3. Offline


    1. public void damage(EntityDamageEvent e){
    2. if (!(e.getCause() == DamageCause.PROJECTILE)) return;
    3. if (!e.getEntity().getLastDamageCause().getEntity().getType().equals(EntityType.ARROW)) return;
    5. e.setCancelled(true);
    7. e.getEntity().getLastDamageCause().getEntity().setVelocity(new Vector(0, 0, 0));
    9. //Make sure you import the bukkit version of the Vector class
    10. //This will set the velocity to 0, 0, 0 so the arrow wont move after the damage event.
    11. }

    I hope this helped you out a little.

  4. You could do what Nateb did, or you could just cancel the event and use e.getEntity().remove();

    Also, Heirteir - EntityType can't equal a Material...
  5. Offline


    Wups I was thinking wrong I will update it
    KingFaris11 likes this.
Thread Status:
Not open for further replies.

Share This Page