"Fixed" FloatingTextParticle yet again

- nametag visibility flags don't work properly, only players show them all the time
- invisibility overrides nametag visibility
- scale 0 triggers asserts on debug builds

..... how hard is it to NOT break these simple things each update Mojang?

closes #1205
This commit is contained in:
Dylan K. Taylor 2017-09-21 19:04:45 +01:00
parent 10f6a0eef0
commit 9bd7f771d3

View File

@ -25,9 +25,13 @@ namespace pocketmine\level\particle;
use pocketmine\entity\Entity;
use pocketmine\entity\Item as ItemEntity;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\AddEntityPacket;
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
use pocketmine\utils\UUID;
class FloatingTextParticle extends Particle{
//TODO: HACK!
@ -77,13 +81,13 @@ class FloatingTextParticle extends Particle{
}
if(!$this->invisible){
$pk = new AddEntityPacket();
$pk = new AddPlayerPacket();
$pk->uuid = UUID::fromRandom();
$pk->username = "";
$pk->entityRuntimeId = $this->entityId;
$pk->type = ItemEntity::NETWORK_ID;
$pk->position = $this->asVector3()->subtract(0, 0.75, 0);
$pk->yaw = 0;
$pk->pitch = 0;
$pk->position = $this->asVector3(); //TODO: check offset
$pk->item = ItemFactory::get(Item::AIR, 0, 0);
$flags = (
(1 << Entity::DATA_FLAG_CAN_SHOW_NAMETAG) |
(1 << Entity::DATA_FLAG_ALWAYS_SHOW_NAMETAG) |
@ -91,7 +95,8 @@ class FloatingTextParticle extends Particle{
);
$pk->metadata = [
Entity::DATA_FLAGS => [Entity::DATA_TYPE_LONG, $flags],
Entity::DATA_NAMETAG => [Entity::DATA_TYPE_STRING, $this->title . ($this->text !== "" ? "\n" . $this->text : "")]
Entity::DATA_NAMETAG => [Entity::DATA_TYPE_STRING, $this->title . ($this->text !== "" ? "\n" . $this->text : "")],
Entity::DATA_SCALE => [Entity::DATA_TYPE_FLOAT, 0.01] //zero causes problems on debug builds
];
$p[] = $pk;