1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved FloatingText Per world

Discussion in 'Development' started by Daniktheboss, Jul 17, 2017.

  1. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    Hello, i want to spawn a floating text in each of the worlds, but it doesnt work.
    PHP:
      public function EntityLevelChangeEvent(EntityLevelChangeEvent $event){
        
    $player $event->getEntity();
        
    $leveln $event->getTarget();
        if(
    $player instanceof Player) {
          foreach(
    $this->config as $coord => $text) {
            
    $coord explode(':'$coord);
            
    $x $coord[0];
            
    $y $coord[1];
            
    $z $coord[2];
            
    $level $coord[3];
            
    $br explode("-"$text);
            if(
    $level == $leveln->getName()){
              foreach(
    $br as $line){
                
    $y round($y-0.32);
                
    $leveln->addParticle(new FloatingTextParticle(new Vector3(intval($x), $yintval($z)), ""$line));
              }
            }
          }
        }
      }
     
  2. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    Fixed it, i need the worlds loaded to put somthing there :facepalm::shoghi:
    PHP:
    $this->getServer()->loadLevel("level1");
    $this->getServer()->loadLevel("level2");
     
    Muqsit and Levi like this.
  3. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    never mind, still doesnt work
     
  4. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    Ok i found it out, i need 1 second delay AFTER the player teleported in the world to set the text
     
  5. Az928

    Az928 Baby Zombie

    Messages:
    140
    GitHub:
    theaz928
    or simply on join:
    $level->addParticle(new FloatingTextParticle($vector, "text"), [$player]); // Basically adds a floating text particle to that player only, no need any delay
     
  6. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    Stupid much?
     
  7. Az928

    Az928 Baby Zombie

    Messages:
    140
    GitHub:
    theaz928
    Maybe you didn't get what I'm saying, I was saying if you set argument 2 of addParticle, it sends the particle directly to player client, If the argument 2 is empty as usual, it adds chunk packet which needs delay to show up
     
    Last edited: Jul 24, 2017
    Levi likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.