Solved Making Bows have unlimited arrows

Discussion in 'Plugin Development' started by DatCookiez, Nov 25, 2013.

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

    DatCookiez

    Hello bukkitiers!

    I was wondering if it was possible to make an event where when you shoot a bow, the arrow is never consumed by the bow. Yes, yes I know there is such thing as 'Infinity' but I am not looking at using that, I don't want any items to be enchanted.

    Thanks.
     
  2. Offline

    jimbo8

    Can't you just check for when a arrow is shot, and then spawn it back to your inventory? That should work.

    realiez
     
    HGPDev likes this.
  3. Offline

    DatCookiez


    Wouldn't this cause lag and the bow to be pulled back twice?
     
  4. Offline

    1Rogue Retired Staff


    He's saying just add another arrow to the player's inventory every time they shoot one
     
    jimbo8 likes this.
  5. Offline

    DatCookiez


    How do I get the player in a 'ProjectileLaunchEvent' ?
     
  6. Offline

    L33m4n123

    • event.getShooter();
    • check if it is an instance of Player
    • cast it to player
    • there you go
     
  7. Offline

    Garris0n

    It would be an awful lot simpler just to add the enchantment...I don't see any reason not to.
     
    mineu999 and Commander9292 like this.
  8. Offline

    zombiekiller753

    DatCookiez

    The way I see it, you have 3 different options:

    1) Add the enchantment

    2) Detect whether the player has the permission, and if so, when a bow is fired, add another arrow to their inventory (Works, but would look kinda weird)

    3) Detect whether the player has the permission, and if so, when a bow is fired, check if the player has an arrow, and if so, launch a new projectile.
     
  9. Offline

    ISHLCMinecraft

    Easy solution:
    Code:java
    1. @EventHandler
    2. public void onBowShoot(EntityShootBowEvent e) {
    3. e.setCancelled(true);
    4. Arrow arrow = e.getEntity().launchProjectile(Arrow.class);
    5. arrow.setVelocity(e.getProjectile().getVelocity());
    6. }
     
  10. Offline

    DatCookiez

  11. Offline

    SourceForums

    DatCookiez
    On EntityShootBowEvent, use:
    Code:java
    1. ItemStack arrow = new ItemStack(Material.ARROW, 1);
    2. player.getInventory.addItem(arrow);
     
    DatCookiez likes this.
  12. Offline

    xTrollxDudex

    Garris0n likes this.
Thread Status:
Not open for further replies.

Share This Page