php 8.1 fixs

This commit is contained in:
ArkQuark 2023-03-25 18:37:40 +03:00
parent 10c126b4d5
commit 9abba9a2a2
13 changed files with 90 additions and 11 deletions

View file

@ -40,7 +40,7 @@ class Arrow extends Projectile{
}
public function spawn($player){
if($this->type === OBJECT_ARROW){
//if($this->type === OBJECT_ARROW){
$pk = new AddEntityPacket;
$pk->eid = $this->eid;
$pk->type = $this->type;
@ -56,6 +56,6 @@ class Arrow extends Projectile{
$pk = new SetEntityMotionPacket;
$pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
$player->dataPacket($pk);
}
//}
}
}

View file

@ -0,0 +1,61 @@
<?php
class Snowball extends Projectile{
const TYPE = OBJECT_SNOWBALL;
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
parent::__construct($level, $eid, $class, $type, $data);
//$this->server->schedule(1210, array($this, "update")); //Despawn
}
public function handleUpdate(){
$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($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
$f2 = sqrt($d * $d + $d1 * $d1 + $d2 * $d2);
$d /= $f2;
$d1 /= $f2;
$d2 /= $f2;
$d += $this->random->nextGaussian() * 0.0075 * $f1; //0.0074999998323619366 replaced with 0.0075
$d1 += $this->random->nextGaussian() * 0.0075 * $f1;
$d2 += $this->random->nextGaussian() * 0.0075 * $f1;
$d *= $f;
$d1 *= $f;
$d2 *= $f;
$this->speedX = $d;
$this->speedY = $d1;
$this->speedZ = $d2;
$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){
//if($this->type === OBJECT_ARROW){
$pk = new AddEntityPacket;
$pk->eid = $this->eid;
$pk->type = $this->type;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->did = 1;
$pk->speedX = $this->speedX;
$pk->speedY = $this->speedY;
$pk->speedZ = $this->speedZ;
$player->dataPacket($pk);
$pk = new SetEntityMotionPacket;
$pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
$player->dataPacket($pk);
//}
}
}

View file

@ -25,6 +25,8 @@ class EntityRegistry{
self::registerEntity(PrimedTNT::class);
self::registerEntity(Painting::class);
self::registerEntity(Minecart::class);
self::registerEntity(Snowball::class);
//self::registerEntity(Egg::class);
}
/*Register an Entity*/