Floating text

Discussion in 'Development' started by fevio, Apr 30, 2020.

  1. fevio

    fevio Spider Jockey

    Messages:
    25
    I searching a code for floating text ,
    I have no idea how do, advice or example of code?
     
  2. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    509
    GitHub:
    GamakCZ
    You can use my api extracted from Texter plugin.

    PHP:
    /** @var Vector3 $vector3 */
    $eid FloatingTextApi::createText($vector3);
    /** @var Player $player */
    FloatingTextApi::sendText($eid$player"My awesome floating text");
     
    ethaniccc and fevio like this.
  3. nexTRushh

    nexTRushh Creeper

    Messages:
    1
    But how does it work if there is more then 1 and i want too delete a specific one
     
  4. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    509
    GitHub:
    GamakCZ
    PHP:
    FloatingTextApi::removeText($eid$player);
     
  5. JviguyGamesYT

    JviguyGamesYT Slime

    Messages:
    86
    GitHub:
    jviguy
    hey im using your api for a plugin which displays names over dropped items kinda need some help i just dont know what to do with the Api sendText Method And How it works This What My Current Code Looks Like
    PHP:
        public function onDrop(PlayerDropItemEvent $e$FloatingTextApi)
        {

            
    $grounditem $e->getItem();
            
    $itemname $e->getItem()->getName();
            
    $player $e->getPlayer();
            
    $pos $player->getPosition();
            
    $text $itemname;
            
    // Spawning text
            
    $textId FloatingTextApi::createText(new vector3($pos)); // $vector3 -> position of floating text, This function is just for initialize
            
    FloatingTextApi::sendText($eId$player ("{$text}\n{$text}")); // This you can use to spawn text, and for update too
        
    }

     
  6. Levi

    Levi Skeleton

    Messages:
    906
    GitHub:
    captainleviftw
    how to update text?
     
  7. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    509
    GitHub:
    GamakCZ
    Just use FloatingTextApi::sendText() function again with same eid
     
  8. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    509
    GitHub:
    GamakCZ
    Use some ide which will show you all the problems in the syntax
     
  9. AffanStarPure

    AffanStarPure Baby Zombie

    Messages:
    106
    GitHub:
    AffanStarPure
    How I support the Multi world Level for floating text?
     
  10. Levi

    Levi Skeleton

    Messages:
    906
    GitHub:
    captainleviftw
    How to spawn in level so it stays there and not just the players?
     
  11. PJZ9n

    PJZ9n Spider

    Messages:
    14
    GitHub:
    pjz9n
    You can treat it like Particles, thanks to PMMP's HACK which treats entities as particles.
    PHP:
    <?php

    declare(strict_types=1);

    use 
    pocketmine\level\Level;
    use 
    pocketmine\level\particle\FloatingTextParticle;
    use 
    pocketmine\math\Vector3;

    //Create
    /** @var Vector3 $pos */
    $particle = new FloatingTextParticle($pos"test\nfoo\nhoge""Title!");//Create the particle
    /** @var Level $level */
    $level->addParticle($particle);//Spawn to level

    //Update
    $particle->setTitle("Updated title!");
    $particle->setText("Updated text!");
    /** @var Level $level */
    $level->addParticle($particle);//Spawn to level

    //Remove
    $particle->setInvisible(true);//Set remove
    $level->addParticle($particle);//Remove!
     
  12. Levi

    Levi Skeleton

    Messages:
    906
    GitHub:
    captainleviftw
    I asked about GamacCZ’s api
     
  13. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    509
    GitHub:
    GamakCZ
    You have to handle PlayerJoinEvent and EntityLevelChangeEvent to make it stay in on one level.
     
  14. Levi

    Levi Skeleton

    Messages:
    906
    GitHub:
    captainleviftw
    Is there a way to do it once and for all on a level?
     

Share This Page

  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.