better entity linking system

This commit is contained in:
GameHerobrine 2025-07-16 12:35:12 +03:00
parent c95a8d5cff
commit d7763f445a
13 changed files with 353 additions and 227 deletions

View file

@ -199,22 +199,25 @@ abstract class Projectile extends Entity{
return $data;
}
public function spawn($player)
public function spawn(Player $player)
{
$player->addEntity($this);
$pk = new AddEntityPacket();
$pk->eid = $this->eid;
$pk->type = $this->type;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->speedX = $this->speedX;
$pk->speedY = $this->speedY;
$pk->speedZ = $this->speedZ;
$pk->did = 0;
$player->entityQueueDataPacket($pk);
return true;
if(!$player->hasEntity($this)){
$player->addEntity($this);
$pk = new AddEntityPacket();
$pk->eid = $this->eid;
$pk->type = $this->type;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->speedX = $this->speedX;
$pk->speedY = $this->speedY;
$pk->speedZ = $this->speedZ;
$pk->did = 0;
$player->entityQueueDataPacket($pk);
$this->sendLinkPackets($player);
return true;
}
return false;
}
}