keyword: FloatingText floating text texts floatingtingtexts I had been trying to send about 15+ floatingtexts and this made my minecraft crash As i see more than 15 packets sending to a player at the same time will make the client crash the game I sent those floating text by a foreach loop PHP: public $array = [];//contains floatingtextparticle class public function onJoin(PlayerJoinEvent $e) { foreach ($this->array as $ftp) { #$e->getPlayer()->getLevel()->addParticle($ftp, [$player]); $pks = $ftp->encode(); foreach($pks as $pk){ $e->getPlayer()->sendDataPacket($pk); } } } Does anyone know how to prevent this or some way to send many floatingtexts to a player
I am sending floating text using addplayerpackets. This method works fine and don't crash client. You can check my api here.
ur code work so good, thanks but however when i have new a large amount of floatingtexts displaying, some other will be removed automaticaly ,is it from client side
i created a new floatingtextclass which extends the original one with some extra function PHP: class FloatingTextParticle extends \pocketmine\level\particle\FloatingTextParticle{ public function sendPk(){ if($this->entityId === null){ $this->entityId = Entity::$entityCount++; } $pk = new AddPlayerPacket(); $pk->username = $this->text; $pk->uuid = UUID::fromRandom(); $pk->entityRuntimeId = $this->entityId; $pk->entityUniqueId = $this->entityId; $pk->position = $this->asVector3(); $pk->item = Item::get(0); $pk->metadata = [ Entity::DATA_FLAGS => [Entity::DATA_TYPE_LONG, 1 << Entity::DATA_FLAG_IMMOBILE], Entity::DATA_SCALE => [Entity::DATA_TYPE_FLOAT, 0.01] ]; return $pk; } public function removePk(){ $pk = new RemoveActorPacket(); $pk->entityUniqueId = $this->entityId; return $pk; } So i dont change any original code for this new change,all i have to do is change these PHP: //"Add particle" method:$level->addParticle($ftp,[$player]);//======Replaced into====$pk = $ftp->sendPk();$player->sendDataPacket($pk); PHP: //"Remove particle" method:$ftp->setInvisible();$level->addParticle($ftp,[$player]);$ftp->setInvisible(false);//======Replaced into======$pk = $ftp->removePk();$player->sendDataPacket($pk); When i want to change the ftp text, i send the same ftp class with the username changed
with many these packet my mc windows10 dont see any lag but my phone is just going to be paralysed, and sometime it still crash the client but not often like before
by the way with many floating text, the game will also be very laggy, do y know why, , and can it be prevented. the game can be quickly more laggy if there are more floating text, i dont think it can be that lag with just a 10-20 floating text