Inheritance: extends EntityEvent, implements pocketmine\event\Cancellable
Exemplo n.º 1
0
 /**
  * @param EntityMotionEvent $event
  */
 public function onPlayerMotion(EntityMotionEvent $event)
 {
     if (isset($this->blockMans[spl_object_hash($event->getEntity())])) {
         foreach ($this->blockMans[spl_object_hash($event->getEntity())] as $p) {
             /** @var $p Player */
             $motion = $event->getEntity()->getMotion();
             $p->addEntityMotion($event->getEntity()->getId(), $motion->getX(), $motion->getY(), $motion->getZ());
         }
     }
 }
Exemplo n.º 2
0
 public function onEntityMotion(EntityMotionEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $et = $ev->getEntity();
     if (!$et instanceof Living) {
         return;
     }
     if ($et instanceof Player) {
         return;
     }
     // Handled through PlayerMoveEvent
     $this->checkMove($et);
 }
Exemplo n.º 3
0
 public function setMotion(Vector3 $motion)
 {
     if (!$this->justCreated) {
         $this->server->getPluginManager()->callEvent($ev = new EntityMotionEvent($this, $motion));
         if ($ev->isCancelled()) {
             return false;
         }
     }
     $this->motionX = $motion->x;
     $this->motionY = $motion->y;
     $this->motionZ = $motion->z;
     if (!$this->justCreated) {
         $this->updateMovement();
     }
     return true;
 }
Exemplo n.º 4
0
 public function onEntityMotion(EntityMotionEvent $event)
 {
     $levelName = $event->getEntity()->getLevel()->getName();
     if (!$this->plugin->isLevelLoaded($levelName)) {
         return;
     }
     $settings = $this->plugin->getLevelSettings($levelName);
     if ($settings->restrictEntityMovement and !$event->getEntity() instanceof Player) {
         $event->setCancelled(true);
     }
 }
Exemplo n.º 5
0
 public function setMotion(Vector3 $motion)
 {
     if (!$this->justCreated) {
         $this->server->getPluginManager()->callEvent($ev = new EntityMotionEvent($this, $motion));
         if ($ev->isCancelled()) {
             return false;
         }
     }
     $this->motionX = $motion->x;
     $this->motionY = $motion->y;
     $this->motionZ = $motion->z;
     if (!$this->justCreated) {
         if ($this instanceof Player) {
             $pk = new SetEntityMotionPacket();
             $pk->entities = [[0, $this->motionX, $this->motionY, $this->motionZ]];
             $this->dataPacket($pk);
         }
         $this->updateMovement();
     }
     return true;
 }
Exemplo n.º 6
0
 public function onPlayerMotion(EntityMotionEvent $event)
 {
     if ($this->gameStatus > 1 && $event->getEntity() instanceof Player && $this->playerIsInGame($event->getEntity()->getName()) === 2) {
         foreach ($event->getEntity()->getLevel()->getPlayers() as $p) {
             $motion = $event->getEntity()->getMotion();
             $p->addEntityMotion($event->getEntity()->getId(), $motion->getX(), $motion->getY(), $motion->getZ());
         }
     }
 }