Shoot arrow perfectly straight

Discussion in 'Plugin Development' started by Minnymin3, Apr 12, 2014.

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

    Minnymin3

    Does anyone know if its actually possible to shoot an arrow perfectly straight but not super fast? I know that I could increase the speed which would decrease the change in height over distance but I want it to also go slowly.
     
  2. Offline

    rohan576

    I'm not sure if this will work, but I think it will. I unfortunately cannot test it right this moment, so I'll leave that to you.

    Code:java
    1. @EventHandler
    2. public void onProjectileThrownEvent(ProjectileLaunchEvent event) {
    3. if (event.getEntity() instanceof Arrow) {
    4. while (!event.getEntity().isOnGround()) {
    5. event.getEntity().setVelocity(event.getEntity().getVelocity());
    6. }
    7. }
    8. }
     
  3. Offline

    GeorgeeeHD

    lol that will crash the server
     
  4. Offline

    rohan576

    Okay, try this then.
    Code:java
    1. @EventHandler
    2. public void onProjectileThrownEvent(ProjectileLaunchEvent event) {
    3. if (event.getEntity() instanceof Arrow) {
    4. int a = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(<your plugin>, new Runnable() {
    5. public void run() {
    6. if (!event.getEntity().isOnGround()) {
    7. event.getEntity().setVelocity(event.getEntity().getVelocity());
    8. }
    9. else {
    10. Bukkit.getServer().getScheduler().cancelTask(a);
    11. }
    12. }
    13. }, 0L, 1);
    14. }
    15. }
     
Thread Status:
Not open for further replies.

Share This Page