1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Shoot arrow via command

Discussion in 'Development' started by Nora1903, Jul 27, 2018.

  1. Nora1903

    Nora1903 Slime

    Messages:
    82
    GitHub:
    cuongvnz
    How to shoot an arrow from player when i enter an command?
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    One way would be using:
    PHP:
    $player->getInventory()->addItem(Item::get(Item::ARROW));
    if(!
    Item::get(Item::BOW)->onReleaseUsing($player)){
        
    $player->getInventory()->removeItem(Item::get(Item::ARROW));
    }
    You won't be skipping event calls that way, but that's also pretty hacky.

    For the not-hacky way, refer to Bow->onReleaseUsing() and see how it shoots an arrow when a player releases bow.
     
  3. Nora1903

    Nora1903 Slime

    Messages:
    82
    GitHub:
    cuongvnz
    I mean to shoot an arrow entity without using bow
     
  4. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.