Implemented swiftness, added invisible status to FloatingTextParticle

This commit is contained in:
Shoghi Cervantes
2015-03-20 17:19:06 +01:00
parent b42424eb22
commit 58253be0a0
4 changed files with 39 additions and 19 deletions

View File

@ -38,6 +38,7 @@ class FloatingTextParticle extends Particle{
protected $text;
protected $title;
protected $entityId;
protected $invisible = false;
public function __construct(Vector3 $pos, $text, $title = ""){
parent::__construct($pos->x, $pos->y, $pos->z);
@ -52,6 +53,14 @@ class FloatingTextParticle extends Particle{
public function setTitle($title){
$this->title = $title;
}
public function isInvisible(){
return $this->invisible;
}
public function setInvisible($value = true){
$this->invisible = (bool) $value;
}
public function encode(){
$p = [];
@ -66,24 +75,27 @@ class FloatingTextParticle extends Particle{
$p[] = $pk0;
}
$pk = new AddPlayerPacket();
$pk->eid = $this->entityId;
$pk->username = $this->title . "\n" . $this->text;
$pk->clientID = $this->entityId;
$pk->x = $this->x;
$pk->y = $this->y - 2;
$pk->z = $this->z;
$pk->yaw = 0;
$pk->pitch = 0;
$pk->item = 0;
$pk->meta = 0;
$pk->metadata = [
Entity::DATA_FLAGS => [Entity::DATA_TYPE_BYTE, 1 << Entity::DATA_FLAG_INVISIBLE],
Entity::DATA_AIR => [Entity::DATA_TYPE_SHORT, 300],
Entity::DATA_SHOW_NAMETAG => [Entity::DATA_TYPE_BYTE, 1]
];
if(!$this->invisible){
$pk = new AddPlayerPacket();
$pk->eid = $this->entityId;
$pk->username = $this->title . "\n" . $this->text;
$pk->clientID = $this->entityId;
$pk->x = $this->x;
$pk->y = $this->y - 2;
$pk->z = $this->z;
$pk->yaw = 0;
$pk->pitch = 0;
$pk->item = 0;
$pk->meta = 0;
$pk->metadata = [
Entity::DATA_FLAGS => [Entity::DATA_TYPE_BYTE, 1 << Entity::DATA_FLAG_INVISIBLE],
Entity::DATA_AIR => [Entity::DATA_TYPE_SHORT, 300],
Entity::DATA_SHOW_NAMETAG => [Entity::DATA_TYPE_BYTE, 1]
];
$p[] = $pk;
$p[] = $pk;
}
return $pk;
}