Atlatl Kit! Help with projectile spawning

Discussion in 'Plugin Development' started by TCO_007, May 5, 2014.

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

    TCO_007

    Hello! I am creating a new kit for my server! The name of the kit is Atlatl. Basically it allows the player to rightclick their arrows/spears and when they do, it shoots and arrow out directly in front of them. I want the arrow to give the player it hits a 33% chance of giving the Player slowness. Bad part is.... I have no idea how to do this. I dont know how to spawn an arrow and give it a velocity and how to make it so that it gives the potion effect to the enemy player (the player the arrow hit). Can anyone help me? This is all I have so far.
    Code:java
    1. @EventHandler
    2. public void onAtlatlThrow(PlayerInteractEvent e){
    3. Player player = e.getPlayer();
    4. if (e.getAction() == Action.RIGHT_CLICK_AIR && player.getItemInHand().getType() == Material.ARROW){
    5. if (player.getGameMode() != GameMode.CREATIVE){
    6. if (player.getItemInHand().getAmount() > 1){
    7. player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
    8. }else{
    9. player.setItemInHand(new ItemStack(Material.AIR)); }
    10. }
    11. }
    12. }
    13. }
     
  2. Offline

    TGRHavoc

    TCO_007
    Something like this maybe...
    Code:java
    1. Arrow arrow = player.launchProjectile(Arrow.class);
    2.  
    3. arrow.setVelocity(player.getLocation().getDirection());
     
Thread Status:
Not open for further replies.

Share This Page