Updated FloatingTextParticle to use less heavy method

This commit is contained in:
Shoghi Cervantes 2015-05-19 21:59:23 +02:00
parent 7753b1d8be
commit 32722856ea
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89
2 changed files with 14 additions and 14 deletions

View File

@ -180,12 +180,13 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
} }
} }
if(strlen($this->getSkinData()) > 0){
$this->namedtag->Skin = new Compound("Skin", [ $this->namedtag->Skin = new Compound("Skin", [
"Data" => new String("Data", $this->getSkinData()), "Data" => new String("Data", $this->getSkinData()),
"Slim" => new Byte("Slim", $this->isSkinSlim() ? 1 : 0) "Slim" => new Byte("Slim", $this->isSkinSlim() ? 1 : 0)
]); ]);
} }
}
public function spawnTo(Player $player){ public function spawnTo(Player $player){
if($player !== $this and !isset($this->hasSpawned[$player->getId()])){ if($player !== $this and !isset($this->hasSpawned[$player->getId()])){

View File

@ -22,8 +22,11 @@
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\entity\Item as ItemEntity;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\network\protocol\AddEntityPacket;
use pocketmine\network\protocol\AddPlayerPacket; use pocketmine\network\protocol\AddPlayerPacket;
use pocketmine\network\protocol\RemoveEntityPacket;
use pocketmine\network\protocol\RemovePlayerPacket; use pocketmine\network\protocol\RemovePlayerPacket;
class FloatingTextParticle extends Particle{ class FloatingTextParticle extends Particle{
@ -62,21 +65,19 @@ class FloatingTextParticle extends Particle{
if($this->entityId === null){ if($this->entityId === null){
$this->entityId = bcadd("1095216660480", mt_rand(0, 0x7fffffff)); //No conflict with other things $this->entityId = bcadd("1095216660480", mt_rand(0, 0x7fffffff)); //No conflict with other things
}else{ }else{
$pk0 = new RemovePlayerPacket(); $pk0 = new RemoveEntityPacket();
$pk0->eid = $this->entityId; $pk0->eid = $this->entityId;
$pk0->clientID = $this->entityId;
$p[] = $pk0; $p[] = $pk0;
} }
if(!$this->invisible){ if(!$this->invisible){
$pk = new AddPlayerPacket(); $pk = new AddEntityPacket();
$pk->eid = $this->entityId; $pk->eid = $this->entityId;
$pk->username = $this->title . ($this->text !== "" ? "\n" . $this->text : ""); $pk->type = ItemEntity::NETWORK_ID;
$pk->clientID = $this->entityId;
$pk->x = $this->x; $pk->x = $this->x;
$pk->y = $this->y - 2.5; $pk->y = $this->y - 0.75;
$pk->z = $this->z; $pk->z = $this->z;
$pk->speedX = 0; $pk->speedX = 0;
$pk->speedY = 0; $pk->speedY = 0;
@ -85,11 +86,9 @@ class FloatingTextParticle extends Particle{
$pk->pitch = 0; $pk->pitch = 0;
$pk->item = 0; $pk->item = 0;
$pk->meta = 0; $pk->meta = 0;
$pk->slim = false;
$pk->skin = str_repeat("\x00", 64 * 32 * 4);
$pk->metadata = [ $pk->metadata = [
Entity::DATA_FLAGS => [Entity::DATA_TYPE_BYTE, 1 << Entity::DATA_FLAG_INVISIBLE], Entity::DATA_FLAGS => [Entity::DATA_TYPE_BYTE, 1 << Entity::DATA_FLAG_INVISIBLE],
Entity::DATA_AIR => [Entity::DATA_TYPE_SHORT, 300], Entity::DATA_NAMETAG => [Entity::DATA_TYPE_STRING, $this->title . ($this->text !== "" ? "\n" . $this->text : "")],
Entity::DATA_SHOW_NAMETAG => [Entity::DATA_TYPE_BYTE, 1], Entity::DATA_SHOW_NAMETAG => [Entity::DATA_TYPE_BYTE, 1],
Entity::DATA_NO_AI => [Entity::DATA_TYPE_BYTE, 1] Entity::DATA_NO_AI => [Entity::DATA_TYPE_BYTE, 1]
]; ];