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

Custom enchant

Discussion in 'Development' started by Hipster, May 4, 2017.

  1. Hipster

    Hipster Zombie

    Messages:
    214
    I m trying to make a custom enchant of bow. When the arrow hits the player, it gives slowness to the player, i tried but i couldn't find how to get the player after the arrow hits the player :/
     
  2. xBeastMode

    xBeastMode Shog Chips

    Messages:
    0
  3. Hipster

    Hipster Zombie

    Messages:
    214
    Look at my question and answer dawg -_-
     
  4. Lowkey

    Lowkey Slime

    Messages:
    94
    PHP:
    public function onDamage(EntityDamageEvent $event){
    if(
    $event instanceof \pocketmine\event\entity\EntityDamageByEntityEvent){
    $damager $event->getDamager();
    if(
    $event instanceof \pocketmine\event\entity\EntityDamageByChildEntityEvent){
    if(
    $damager instanceof \pocketmine\Player){
    $player $event->getEntity();
         }
       }
      }
    }
     
    Hipster likes this.
  5. Hipster

    Hipster Zombie

    Messages:
    214
    But how will it detect it was by an arrow?
     
  6. Lowkey

    Lowkey Slime

    Messages:
    94
    Public attributes for the class;
    PHP:
    MODIFIER_BASE 0
     
    const     MODIFIER_ARMOR 1
     
    const     CAUSE_CONTACT 0
     
    const     CAUSE_ENTITY_ATTACK 1
     
    const     CAUSE_PROJECTILE 2
     
    const     CAUSE_SUFFOCATION 3
     
    const     CAUSE_FALL 4
     
    const     CAUSE_FIRE 5
     
    const     CAUSE_FIRE_TICK 6
     
    const     CAUSE_LAVA 7
     
    const     CAUSE_DROWNING 8
     
    const     CAUSE_BLOCK_EXPLOSION 9
     
    const     CAUSE_ENTITY_EXPLOSION 10
     
    const     CAUSE_VOID 11
     
    const     CAUSE_SUICIDE 12
     
    const     CAUSE_MAGIC 13
     
    const     CAUSE_CUSTOM 14
    You can see that the second constant is projectile!
     
    Hipster likes this.
  7. Hipster

    Hipster Zombie

    Messages:
    214
    Ohhh damn you're good, thnx lowkey, thnx for nothing xbeast -_-
     
    Lowkey likes this.
  8. Lowkey

    Lowkey Slime

    Messages:
    94
    I think he just read your post too fast, forgive him :)
     
    Hipster likes this.
  9. Hipster

    Hipster Zombie

    Messages:
    214
  10. xBeastMode

    xBeastMode Shog Chips

    Messages:
    0
    I just thought they might help I didn't say anything.
     
  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.