Bat damage

Discussion in 'Development' started by SergeyIvanov, Oct 14, 2017.

  1. SergeyIvanov

    SergeyIvanov Witch

    Messages:
    59
    GitHub:
    sergeyivanov14
    Hello, why my code don't work? No errors

    My code:
    PHP:
        public function onDmg(EntityDamageEvent $event){
            if(
    $event instanceof EntityDamageByEntityEvent){
                
    $player $event->getEntity();
                
    $damager $event->getDamager();
                if(
    $damager instanceof Player){
                    
    $nick strtolower($damager->getName());
                    if(
    $player instanceof Bat){
                        
    $event->setCancelled(true);

                        
    $damager->sendMessage("click");
                    }
                }
            }
        }
    I spawn the bat:
    PHP:
    $w = new AddEntityPacket();
    $w->type 19;
    $w->eid Entity::$entityCount++;
    $flags 0;
    $flags |= << Entity::DATA_FLAG_SILENT;
    $flags |= << Entity::DATA_FLAG_NO_AI;
    $w->metadata = [
      
    Entity::DATA_FLAGS => [Entity::DATA_TYPE_LONG$flags],
      
    Entity::DATA_NAMETAG => [Entity::DATA_TYPE_STRING"bat1"]
     ];
    $w->speedX 0;
    $w->speedY 0;
    $w->speedZ 0;
    $w->yaw 270;
    $w->pitch 0;
    $w->$player->x;
    $w->$player->y+5;
    $w->$player->z;
    $player->dataPacket($w);
     
  2. jasonwynn10

    jasonwynn10 Wither Skeleton Poggit Reviewer Verified

    Messages:
    1,276
    GitHub:
    jasonwynn10
    What you've done is spawned a bat only to one client without registering it with the server
     
  3. SergeyIvanov

    SergeyIvanov Witch

    Messages:
    59
    GitHub:
    sergeyivanov14
    Can you help me with normal code?
     
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    675
    To spawn bat use Entity::createEntity()
     
  5. SergeyIvanov

    SergeyIvanov Witch

    Messages:
    59
    GitHub:
    sergeyivanov14
    If i use createEntity bat can fly.
     
  6. Kyd

    Kyd Zombie Pigman

    Messages:
    675
    Use data flag NO_AI
     
  7. SergeyIvanov

    SergeyIvanov Witch

    Messages:
    59
    GitHub:
    sergeyivanov14
    If i paste NO AI damage dont work.
     
  8. SergeyIvanov

    SergeyIvanov Witch

    Messages:
    59
    GitHub:
    sergeyivanov14
    I can give you 10$ on PayPal.
     
  9. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    453
    GitHub:
    InspectorGadget
    I see business...
     

Share This Page

  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.