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); }
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; }
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; }