diff --git a/src/Player.php b/src/Player.php index 014d4583..793d3960 100755 --- a/src/Player.php +++ b/src/Player.php @@ -1692,7 +1692,6 @@ class Player{ case 5: //Shot arrow if($this->entity->inAction === true){ if($this->getSlot($this->slot)->getID() === BOW){ - console($this->getSlot($this->slot)->getMetadata()); if($this->startAction !== false){ $time = microtime(true) - $this->startAction; $d = array( @@ -1706,8 +1705,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*2, 1.0); - console($e->yaw); + $e->shoot($e->speedX, $e->speedY, $e->speedZ, 1.5, 1.0); $this->server->api->entity->spawnToAll($e); } } diff --git a/src/entity/object/Arrow.php b/src/entity/object/Arrow.php index 8698c729..eafabd5e 100644 --- a/src/entity/object/Arrow.php +++ b/src/entity/object/Arrow.php @@ -5,31 +5,49 @@ class Arrow extends Projectile{ function __construct(Level $level, $eid, $class, $type = 0, $data = array()){ parent::__construct($level, $eid, $class, $type, $data); $this->server->schedule(1210, array($this, "update")); //Despawn - $this->update(); } - + public function update(){ + $f3 = 0.99; + $f5 = 0.03; + $this->move(new Vector3($this->speedX, $this->speedY, $this->speedZ)); + $this->updateMovement(); + $this->speedX *= $f3; + $this->speedZ *= $f3; + $this->speedY -= $f5; + $this->server->api->handle("entity.move", $this); + $this->handleUpdate(); + $this->server->schedule(1, array($this, "update")); + } + public function handleUpdate(){ + $players = $this->server->api->player->getAll($this->level); + $pk = new MoveEntityPacket_PosRot; + $pk->eid = $this->eid; + $pk->x = $this->x; + $pk->y = $this->y; + $pk->z = $this->z; + $pk->yaw = $this->yaw; + $pk->pitch = $this->pitch; + $this->server->api->player->broadcastPacket($players, $pk); + } public function environmentUpdate(){ parent::environmentUpdate(); $time = microtime(true); if(($time - $this->spawntime) >= 60){ $this->close(); return false; - }else{ - /*$f3 = 0.99; - $f5 = 0.03; - $this->speedX *= $f3; - $this->speedY *= $f3; - $this->speedZ *= $f3; - $this->speedY -= $f5; - $this->move(new Vector3($this->speedX, $this->speedY, $this->speedZ), $this->yaw, $this->pitch); - $this->updateMovement(); - return true;*/ - return false; } + return true; + } + public function setMotion(){ + $pk = new SetEntityMotionPacket; + $pk->eid = $this->eid; + $pk->speedX = $this->speedX; + $pk->speedY = $this->speedY; + $pk->speedZ = $this->speedZ; + $this->server->api->player->broadcastPacket($this->level->players, $pk); } public function shoot($d, $d1, $d2, $f, $f1){ //original name from 0.8.1 IDA decompilation, var names are taken from b1.7.3 $random = new Random(); - console($d." ".$d1." ".$d2." ".$f." ".$f1); $f2 = sqrt($d * $d + $d1 * $d1 + $d2 * $d2); $d /= $f2; $d1 /= $f2; @@ -46,6 +64,7 @@ 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->update(); //TODO i guess? $ticksInGround = 0; } public function spawn($player){