Create A Vector

Discussion in 'Spigot Plugin Development' started by eli.musgrove9, May 13, 2015.

  1. ^ :p
     
    • Friendly Friendly x 1
  2. Thanks for all the help everyone! Final code for anyone who wants it:
    I also added it to damage the player so the arrow doesn't have to hit them to damage them!

    Code (Text):
    for (Entity entity : player.getNearbyEntities(5, 5, 5)) {
                        if (entity instanceof Player) {
                            final Player affected = (Player) entity;
                            Location pLoc = affected.getLocation();
                            pLoc.setY(pLoc.getY() + 20);
                            Vector directionVector = pLoc.getDirection();
                            directionVector.setY(-20);
                            directionVector.multiply(10.0);
                            directionVector = directionVector.normalize();
                            affected.getWorld().spawnArrow(pLoc, directionVector, 0.6f, 0);
                            Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                                public void run() {
                                    affected.damage(10);
                                }
                            }, 20);
                            abilitycooldown.add(player);
                        }
                    }
     
  3. Thanks for the rate! <3
     
  4. Np XD
     
  5. Also, add arrow.setCritical(true) to make it even more awesome :D ^_^

    Code (Java):

    for (Entity entity : player.getNearbyEntities(5, 5, 5)) {
                        if (entity instanceof Player) {
                            final Player affected = (Player) entity;
                            Location pLoc = affected.getLocation();
                            pLoc.setY(pLoc.getY() + 20);
                            Vector directionVector = pLoc.getDirection();
                            directionVector.setY(-20);
                            directionVector.multiply(10.0);
                            directionVector = directionVector.normalize();
                            affected.getWorld().spawnArrow(pLoc, directionVector, 0.6f, 0).setCritical(true);
                            Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                                public void run() {
                                    affected.damage(10);
                                }
                            }, 20);
                            abilitycooldown.add(player);
                        }
                    }
     
     
    • Winner Winner x 1
  6. Oh my gerd.. this thread will not end
     
    • Funny Funny x 1