Bow Without Arrows

Discussion in 'Plugin Development' started by RealDope, Aug 14, 2013.

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


    I've seen this problem before, with no definitive solution besides "make it an infinity bow and give the player one arrow".

    I don't want the bow to be enchanted, and I don't want to have to give the player an arrow.

    I also don't want to just project an arrow when the player right clicks with a bow, I want the entire drawback animation, as well as different powers depending on drawback quantity.

    There must be a way to do this..

    ALSO: This happens in creative mode. If you have a bow in creative you don't need infinity or an arrow to shoot.
  2. Offline


    Use a ProjectileLaunchEvent, check for whatever and then cancel it. Launch a projectile.
    Pseudo code:
    public void onArrowShoot(ProjectileLaunchEvent event){
    if event shooter is an instance of Player && shot projectile is an arrow:
  3. Offline


    Uhm.. How does this help me at all?
  4. hey maybe try onrightclick with bow set their gm to creative then back to survival?
  5. Offline


    RealDope It checks to see if the player shot an arrow, and then cancels that. It then shoots the arrow with code, giving the impression that "no arrows were used"..?
  6. Offline


    Oh sorrry, maybe my description wasn't clear. I want a player to be able to shoot the bow without having any arrows in their inventory. If you aren't carrying an arrow, you cant't even start the drawback animation, I want to change that.
  7. Offline


    RealDope yep I didn't understand, sorry! :p
    Maybe something with packets?
  8. Offline


    Yeah maybe, but what but I feel like the best I could do with packets is force the client to display the drawback animation, and it seems like it would be very difficult to link drawback amount with force applied to the arrow.
  9. Offline


    Why not just spawn an arrow every time while listening to PlayerInteractEvent, and create a scheduler to iterate through the player's inventory and check to see if the spawned ItemStack is still there?
    OHQCraft likes this.
  10. kuuichi what if their inven is full :( I've tried without success to do this :( maybe try nms code?
  11. Offline


    Actually I think I'll work with Kuuichi idea and fix XxShadow_NinjaxxX problem by saving the itemstack that the arrow replaces and putting it back after the player shoots.

    Other ideas to actually effectively do this without an arrow at all would still be very much appreciated.
  12. Offline


  13. Offline


    You can do this by sending a packet to set a fake arrow in the inventory, I have done this in my plugin ElementalArrows.
    RealDope, Axe2760 and Kuuichi like this.
  14. Offline


    Thanks a ton! That's exactly what I wanted.

    To clarify, you are referring to this:
    2. Packet103SetSlot packet = new Packet103SetSlot(0, 9, new ItemStack(Item.ARROW));

    OHQCraft likes this.
  15. Offline


    Yes ;)
    RealDope likes this.
  16. Offline


    (Sorry for necroposting)

    Cybermaxke How exactly do i send this packet to the player ?
    1. packet.handle(new Connection());

    1. new Connection(packet.a());
  17. Offline


    Woah, weird. I was browsing threads helping people, clicked this one and saw I was OP :eek:
    2. ((CraftPlayer) p).getHandle().playerConnection.sendPacket(new Packet103SetSlot(0, 9, new ItemStack(Item.ARROW));
Thread Status:
Not open for further replies.

Share This Page