示例#1
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);
 }
示例#2
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;
 }
示例#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) {
         if ($this instanceof Player) {
             $pk = new SetEntityMotionPacket();
             $pk->entities = [[0, $this->motionX, $this->motionY, $this->motionZ]];
             $this->dataPacket($pk);
         }
         $this->updateMovement();
     }
     return true;
 }