getEntity() public method

public getEntity ( ) : Item
return pocketmine\entity\Item
Esempio n. 1
0
 public function onDrops(ItemSpawnEvent $event)
 {
     $e = $event->getEntity();
     $vec = "{$e->x}:{$e->y}:{$e->z}";
     if (isset($this->itemQueue[$vec])) {
         unset($this->itemQueue[$vec]);
         $reflection_class = new \ReflectionClass($e);
         foreach ($reflection_class->getProperties() as $properties) {
             if ($properties->getName() == 'age') {
                 $property = $reflection_class->getProperty('age');
                 $property->setAccessible(true);
                 if ($property->getValue($event->getEntity()) == 0) {
                     $property->setValue($event->getEntity(), 7000);
                 }
             }
         }
     }
 }
Esempio n. 2
0
 public function onItemSpawn(ItemSpawnEvent $event)
 {
     $entity = $event->getEntity();
     $i = $entity->getItem();
     $item = $i->getID() . ":" . $i->getDamage() . ":" . $i->getCount();
     if (isset($this->item[$item])) {
         unset($this->item[$item]);
         $entity->close();
     }
 }
Esempio n. 3
0
 public function onItemSpawn(ItemSpawnEvent $event)
 {
     $entityitem = $event->getEntity();
     $itemitem = $entityitem->getItem();
     if ($itemitem->getId() === Item::BRICK) {
         $this->crackers[count($this->crackers)] = $this->getServer()->getScheduler()->scheduleDelayedTask(new ExplodeCracker($this, $entityitem, count($this->crackers)), 60)->getTaskId();
         if (count($this->crackers) > 0) {
             if ($this->particlesoundtask === null) {
                 $this->particlesoundtask = $this->getServer()->getScheduler()->scheduleRepeatingTask(new ParticleSound($this), 10)->getTaskId();
             }
         }
         $entityitem->setPickupDelay(300);
         $entityitem->setNameTagVisible(true);
         $entityitem->setNameTag(TextFormat::RED . ($this->getConfig()->get("translation") !== false ? $this->getConfig()->get("translation") : "Firecracker"));
     }
 }