Inheritance: extends Entity, implements Damageable
 /**
  * @param Living $entity
  * @param Item[] $drops
  */
 public function __construct(Living $entity, array $drops = [])
 {
     $this->entity = $entity;
     $this->drops = $drops;
     if ($entity->getLastDamageCause() instanceof EntityDamageByEntityEvent) {
         $entity->getLevel()->addExperienceOrb($entity->add(0, 1, 0), mt_rand(3, 11));
     }
 }
Ejemplo n.º 2
0
 public function spawnTo(Player $player)
 {
     $pk = $this->addEntityDataPacket($player);
     $pk->type = MagmaCube::NETWORK_ID;
     $player->dataPacket($pk);
     parent::spawnTo($player);
 }
Ejemplo n.º 3
0
 public function attack($damage, EntityDamageEvent $source)
 {
     parent::attack($damage, $source);
     if (!$source->isCancelled() and $source->getCause() == EntityDamageEvent::CAUSE_ENTITY_ATTACK) {
         $this->attackingTick = 20;
     }
 }
Ejemplo n.º 4
0
 /**
  * @param Living $entity
  * @param Item[] $drops
  */
 public function __construct(Living $entity, array $drops = [])
 {
     $this->entity = $entity;
     $this->drops = $drops;
     if ($entity->getLastDamageCause() instanceof EntityDamageByEntityEvent) {
         if ($entity->getLastDamageCause()->getDamager() instanceof Player) {
             $p = $entity->getLastDamageCause()->getDamager();
             $pk = new AddEntityPacket();
             $pk->type = ExperienceOrb::NETWORK_ID;
             $pk->eid = Entity::$entityCount++;
             $pk->x = $p->getX();
             $pk->y = $p->getY();
             $pk->z = $p->getZ();
             $pk->speedX = 0;
             $pk->speedY = 0;
             $pk->speedZ = 0;
             $pk->metadata = [0 => [0, 0], 1 => [1, 300], 2 => [4, ""], 3 => [0, 1], 4 => [0, 0], 15 => [0, 0]];
             foreach ($this->entity->getViewers() as $pa) {
                 $pa->dataPacket($pk);
             }
         }
     }
 }
Ejemplo n.º 5
0
 public function spawnTo(Player $player)
 {
     $pk = new AddEntityPacket();
     $pk->eid = $this->getId();
     $pk->type = Slime::NETWORK_ID;
     $pk->x = $this->x;
     $pk->y = $this->y;
     $pk->z = $this->z;
     $pk->speedX = $this->motionX;
     $pk->speedY = $this->motionY;
     $pk->speedZ = $this->motionZ;
     $pk->yaw = $this->yaw;
     $pk->pitch = $this->pitch;
     $pk->metadata = $this->dataProperties;
     $player->dataPacket($pk);
     parent::spawnTo($player);
 }