Inheritance: extends EntityEvent, implements pocketmine\event\Cancellable
Example #1
0
 public function setPowered(bool $powered, Lightning $lightning = null)
 {
     if ($lightning != null) {
         $powered = true;
         $cause = CreeperPowerEvent::CAUSE_LIGHTNING;
     } else {
         $cause = $powered ? CreeperPowerEvent::CAUSE_SET_ON : CreeperPowerEvent::CAUSE_SET_OFF;
     }
     $this->getLevel()->getServer()->getPluginManager()->callEvent($ev = new CreeperPowerEvent($this, $lightning, $cause));
     if (!$ev->isCancelled()) {
         $this->namedtag->powered = new ByteTag("powered", $powered ? 1 : 0);
         $this->setDataProperty(self::DATA_POWERED, self::DATA_TYPE_BYTE, $powered ? 1 : 0);
     }
 }