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

Place a sign with text

Discussion in 'Development' started by Levi, Mar 27, 2019.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    How do I place a sign with text using setBlock()?
    i tried
    PHP:
    $level $p->getLevel();
    $sign Block::get(Block::SIGN_POST);
    $level->setBlock(new Vector3(0,105,0), $sign);
            
    $block $level->getBlockAt(10,105,0);
            
    $tile $level->getTile($block);
            if(
    $tile instanceof Sign){
                
    $tile->setText("line1,","2","3","4");
            }
    it was placing the sign but it wasn't setting the lines
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    The coordinates you set the block and get the tile are not the same
    You need to create the tile yourself, setblock doesnt create the tile for you
     
  3. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Create tile?
     
  4. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    PHP:
    /** @var Level $level */
    /** @var Position $pos */
    $tile Tile::createTile(Tile::SIGN$levelSign::createNBT($pos));
     
  5. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Ok. I still setBlock() like I showed up there, no?
     
  6. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    yes
     
  7. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    the sign is placed with no text at all..
    I set line and text
     
  8. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    can you show your code?
     
  9. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    PHP:
    $x $player->x;
            
    $y $player->y;
            
    $z $player->z;
            
    $sign Block::get(Block::SIGN_POST);
            
    $tile Tile::createTile(Tile::SIGN$levelSign::createNBT(new Vector3($x,$y,$z)));
            
    $level->addTile($tile);
            
    $level->setBlock(new Vector3($x,$y,$z), $sign);
            
    $block $level->getBlockAt((int)$x,(int)$y,(int)$z);
            
    $tile $level->getTile($block);
            if(
    $tile instanceof Sign){
                
    $tile->setText(:"Hellow");
                
    $tile->setLine(1,"Sup dawg");
            }
     
  10. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    you defined it a second time, just use the first one
    also set the block before creating the tile
     
  11. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    It works now but sometimes the sign is invisible or there's no text on it
     
  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.