mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 03:59:43 +00:00
small fixes for new physics, still buggy, needs collision checking
This commit is contained in:
parent
f9a11b5eba
commit
faeb22205f
2 changed files with 34 additions and 17 deletions
|
|
@ -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){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue