/** * @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)); } }
/** * @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); } } } }