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

Solved Make projectiles go through player

Discussion in 'Development' started by IceCruelStuff, Jan 19, 2021.

  1. IceCruelStuff

    IceCruelStuff Silverfish

    Messages:
    16
    GitHub:
    icecruelstuff
    Hi, how can I make arrows go through a specific player?
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Make a class that extends pocketmine\entity\projectile\Arrow, override Arrow::canCollideWith() with whatever your check is, and register the custom arrow class the same way pocketmine register the original class
     
    Primus and SleepSpace9 like this.
  3. IceCruelStuff

    IceCruelStuff Silverfish

    Messages:
    16
    GitHub:
    icecruelstuff
    How can I make it use the custom arrow class whenever I shoot with a bow?
     
  4. IceCruelStuff

    IceCruelStuff Silverfish

    Messages:
    16
    GitHub:
    icecruelstuff
    Also do I have to create a custom name for the arrow class when I register it?
     
  5. Moonafic

    Moonafic Silverfish

    Messages:
    24
    extend bow class and override onReleaseUsing
     
  6. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    The class name does not matter, as long as you register it the same way pocketmine registers the original class
    PHP:
    Entity::registerEntity(Arrow::class, false, ['Arrow''minecraft:arrow']);
    the bow (and anything that spawn arrows) will automatically use your class when it shoots an arrow.
     
  7. IceCruelStuff

    IceCruelStuff Silverfish

    Messages:
    16
    GitHub:
    icecruelstuff
    Thanks
     
  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.