How to shoot arrows instantly?

Discussion in 'Plugin Development' started by JavaNaza, Feb 22, 2018.

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

    JavaNaza

    Hey guys, I wanna know how to make that plugin, when a player holds a bow and they use right click button they can shoot arrows instantly.
    Like there is a 64 arrows so each arrow will get shot after 0.3 sec . Can somebody make it and show that code to me ?

    Thank you !
     
  2. Offline

    timtower Administrator Administrator Moderator

    @JavaNaza Might be the PlayerInteractEvent
     
  3. Offline

    JavaNaza

    I need code, cuz I have no idea how to make that short cooldown...
     
  4. Offline

    timtower Administrator Administrator Moderator

    What have you tried?
     
  5. Well if the player has a real arrow in their inventory, they will show the bow charging animation still. It could make for a better effect if you used a resource pack to have fake arrows, but I get the problem with that.

    My go-to cooldown method is to timestamp the player from when they last fired the arrow (using System.currentTimeMillis), and then the next time they attempt to fire the arrow, check if the cooldown has been 0.3 seconds yet.

    As for shooting arrows, you could use player.launchProjectile and test out the velocity values (note: velocity is on a tick basis- something will move [speed]/tick blocks bearing drag and gravity- so if you have a velocity of 0.05, initially this will cause the arrow to travel 0.05 blocks per tick).
     
Thread Status:
Not open for further replies.

Share This Page