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

Create Sign Tile?

Discussion in 'Development' started by Muqsit, Jan 24, 2017.

  1. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    I am trying to create a sign tile (+ block placement). But the sign text doesn't seem to appear. I logged the sign texts and it reads the sign texts (doesn't return null).

    I also logged the world, looks like the sign tile isn't created at all.
    Here's the code:
    PHP:
    /** @var Position $position */
    /** @var Vector3 $vector */
    $chunk $pos->getLevel()->getChunk($vector->>> 4$vector->>> 4);
    /**
    * $block = [
    *     Block::getId(),
    *     Block::getDamage()
    * ];
    */
    $pos->getLevel()->setBlock($vectorBlock::get($block[0], $block[1]), true);
    /** @var string[] $data */
    $nbt = new CompoundTag("", [
        
    "id" => new StringTag("id"Tile::SIGN),
        
    "x" => new IntTag("x"$vector->x),
        
    "y" => new IntTag("y"$vector->y),
        
    "z" => new IntTag("z"$vector->z),
        
    "Text1" => new StringTag("Text1"$data["Text1"]),
        
    "Text2" => new StringTag("Text2"$data["Text2"]),
        
    "Text3" => new StringTag("Text3"$data["Text3"]),
        
    "Text4" => new StringTag("Text4"$data["Text4"])
    ]);
    Tile::createTile("Sign"$chunk$nbt);
     
  2. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    How about spawning it?
    PHP:
    /** @var Position $position */
    /** @var Vector3 $vector */
    $chunk $pos->getLevel()->getChunk($vector->>> 4$vector->>> 4);
    /**
    * $block = [
    *     Block::getId(),
    *     Block::getDamage()
    * ];
    */
    $pos->getLevel()->setBlock($vectorBlock::get($block[0], $block[1]), true);
    /** @var string[] $data */
    $nbt = new CompoundTag("", [
        
    "id" => new StringTag("id"Tile::SIGN),
        
    "x" => new IntTag("x"$vector->x),
        
    "y" => new IntTag("y"$vector->y),
        
    "z" => new IntTag("z"$vector->z),
        
    "Text1" => new StringTag("Text1"$data["Text1"]),
        
    "Text2" => new StringTag("Text2"$data["Text2"]),
        
    "Text3" => new StringTag("Text3"$data["Text3"]),
        
    "Text4" => new StringTag("Text4"$data["Text4"])
    ]);
    $tile Tile::createTile(Tile::SIGN$chunk$nbt);
    $tile->spawnToAll();
     
    Muqsit likes this.
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Oh my...I don't know how to thank you. I just wasted half an hour..
     
    jasonwynn10 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.