setDrops() публичный Метод

public setDrops ( array $drops )
$drops array
Пример #1
0
 public function EntityDeathEvent(EntityDeathEvent $ev)
 {
     $entity = $ev->getEntity();
     if (!$entity instanceof BaseEntity or !isset(self::$drops[$entity::NETWORK_ID])) {
         return;
     }
     $drops = [];
     foreach (self::$drops[$entity::NETWORK_ID] as $key => $data) {
         if (!isset($data[0]) || !isset($data[1]) || !isset($data[2])) {
             unset(self::$drops[$entity::NETWORK_ID][$key]);
             continue;
         }
         $count = explode(",", $data[2]);
         $item = Item::get($data[0], $data[1]);
         $item->setCount(max(mt_rand(...$count), 0));
         $drops[] = $item;
     }
     $ev->setDrops($drops);
 }
Пример #2
0
 public function AllDeath(EntityDeathEvent $event)
 {
     $entity = $event->getEntity();
     //if ($entity instanceof Zombie) {
     $eid = $entity->getID();
     if (isset($this->animals[$eid])) {
         $ani =& $this->animals[$eid];
         if (in_array($ani['type'], $this->daytype)) {
             $this->animal_A = $this->animal_A - 1;
             //var_dump($this->animal_A);
             unset($this->animals[$eid]);
         } else {
             $this->mob_A = $this->mob_A - 1;
             unset($this->animals[$eid]);
         }
         $ok = mt_rand(0, 100);
         if ($ok < 30) {
             //掉骨头
             $drop = array(new Item(352));
         } elseif ($ok >= 30 and $ok < 50) {
             //掉羽毛
             $drop = array(new Item(288));
         } elseif ($ok >= 50 and $ok < 60) {
             //掉胡萝卜
             $drop = array(new Item(391));
         } elseif ($ok >= 60 and $ok < 70) {
             //掉土豆
             $drop = array(new Item(392));
         } elseif ($ok >= 70 and $ok < 75) {
             //掉蜘蛛丝
             $drop = array(new Item(287));
         } elseif ($ok >= 75 and $ok < 80) {
             //掉石英
             $drop = array(new Item(406));
         } elseif ($ok >= 80 and $ok < 85) {
             //掉铁锭
             $drop = array(new Item(265));
         } elseif ($ok >= 85 and $ok < 90) {
             //掉金锭
             $drop = array(new Item(266));
         } elseif ($ok >= 90 and $ok < 95) {
             //掉甘蔗
             $drop = array(new Item(338));
         } elseif ($ok >= 95 and $ok < 100) {
             //掉萤石粉
             $drop = array(new Item(348));
         } elseif ($ok == 100) {
             //掉钻石
             $drop = array(new Item(264));
         } else {
             $drop = array();
         }
         $event->setDrops($drop);
     }
 }
Пример #3
0
 public function EntityDeathEvent(EntityDeathEvent $ev)
 {
     $entity = $ev->getEntity();
     if (!$entity instanceof BaseEntity or !isset(self::$drops[$entity::NETWORK_ID])) {
         return;
     }
     $drops = [];
     foreach (self::$drops[$entity::NETWORK_ID] as $data) {
         $item = Item::get($data[0], $data[1]);
         $item->setCount(mt_rand(...explode(",", $data[2])));
         $rand = explode("/", $data[3]);
         if (mt_rand(...$rand) <= $rand[0]) {
             $drops[] = $item;
         }
     }
     $ev->setDrops($drops);
 }