mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 04:59:46 +00:00
arrows will fly a bit better now
This commit is contained in:
parent
b455b7891a
commit
4de7707532
2 changed files with 26 additions and 1 deletions
|
|
@ -1726,7 +1726,7 @@ class Player{
|
||||||
$e->speedX = -sin(($e->yaw / 180) * M_PI) * cos(($e->pitch / 180) * M_PI);
|
$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->speedZ = cos(($e->yaw / 180) * M_PI) * cos(($e->pitch / 180) * M_PI);
|
||||||
$e->speedY = -sin(($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);
|
$this->server->api->entity->spawnToAll($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ class Arrow extends Projectile{
|
||||||
const TYPE = OBJECT_ARROW;
|
const TYPE = OBJECT_ARROW;
|
||||||
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||||
parent::__construct($level, $eid, $class, $type, $data);
|
parent::__construct($level, $eid, $class, $type, $data);
|
||||||
|
$this->gravity = 0.05;
|
||||||
//$this->server->schedule(1210, array($this, "update")); //Despawn
|
//$this->server->schedule(1210, array($this, "update")); //Despawn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -35,10 +36,34 @@ class Arrow extends Projectile{
|
||||||
$f3 = sqrt($d * $d + $d2 * $d2);
|
$f3 = sqrt($d * $d + $d2 * $d2);
|
||||||
$this->yaw = (atan2($d, $d2) * 180) / M_PI;
|
$this->yaw = (atan2($d, $d2) * 180) / M_PI;
|
||||||
$this->pitch = (atan2($d1, $f3) * 180) / M_PI;
|
$this->pitch = (atan2($d1, $f3) * 180) / M_PI;
|
||||||
|
$this->sendMotion();
|
||||||
|
$this->updatePosition();
|
||||||
$this->update();
|
$this->update();
|
||||||
//TODO i guess? $ticksInGround = 0;
|
//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){
|
public function spawn($player){
|
||||||
if($this->type === OBJECT_ARROW){
|
if($this->type === OBJECT_ARROW){
|
||||||
$pk = new AddEntityPacket;
|
$pk = new AddEntityPacket;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue