diff --git a/src/Player.php b/src/Player.php index 24630289..494b9588 100755 --- a/src/Player.php +++ b/src/Player.php @@ -1726,7 +1726,7 @@ class Player{ $e->speedX = -sin(($e->yaw / 180) * M_PI) * cos(($e->pitch / 180) * M_PI); $e->speedZ = cos(($e->yaw / 180) * M_PI) * cos(($e->pitch / 180) * M_PI); $e->speedY = -sin(($e->pitch / 180) * M_PI); - $e->shoot($e->speedX, $e->speedY, $e->speedZ, 1.5, 1.0); + $e->shoot($e->speedX, $e->speedY, $e->speedZ, 1.5, 1.5); //TODO bow power $this->server->api->entity->spawnToAll($e); } } diff --git a/src/entity/object/Arrow.php b/src/entity/object/Arrow.php index 7d85145c..2bee1563 100644 --- a/src/entity/object/Arrow.php +++ b/src/entity/object/Arrow.php @@ -4,6 +4,7 @@ class Arrow extends Projectile{ const TYPE = OBJECT_ARROW; function __construct(Level $level, $eid, $class, $type = 0, $data = []){ parent::__construct($level, $eid, $class, $type, $data); + $this->gravity = 0.05; //$this->server->schedule(1210, array($this, "update")); //Despawn } @@ -35,10 +36,34 @@ class Arrow extends Projectile{ $f3 = sqrt($d * $d + $d2 * $d2); $this->yaw = (atan2($d, $d2) * 180) / M_PI; $this->pitch = (atan2($d1, $f3) * 180) / M_PI; + $this->sendMotion(); + $this->updatePosition(); $this->update(); //TODO i guess? $ticksInGround = 0; } + public function update(){ + //parent::update(); + $this->needsUpdate = true; + + $this->speedY -= $this->gravity; + + $this->speedX *= 0.99; + $this->speedY *= 0.99; + $this->speedZ *= 0.99; + + if($this->speedX != 0 or $this->speedY != 0 or $this->speedZ != 0){ + $f = sqrt(($this->speedX * $this->speedX) + ($this->speedZ * $this->speedZ)); + $this->yaw = (atan2($this->speedX, $this->speedZ) * 180 / M_PI); + $this->pitch = (atan2($this->speedY, $f) * 180 / M_PI); + } + $this->x += $this->speedX; + $this->y += $this->speedY; + $this->z += $this->speedZ; + $this->sendMotion(); + $this->updatePosition(); + } + public function spawn($player){ if($this->type === OBJECT_ARROW){ $pk = new AddEntityPacket;