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

BlockEventPacket

Discussion in 'Development' started by MioTaku, Feb 18, 2017.

  1. MioTaku

    MioTaku Witch

    Messages:
    69
    GitHub:
    uselesswaifu
    How to use BlockEventPacket to change the text on a sign
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You really don't need to directly to packets to change a sign'd text. You can use Level::getTile(Vector3) and check if it's an instanceof Sign tile, then Tile::setText(string 1, string 2, string 3, string 4)
     
  3. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    I guess his need is to change text only for a particular player. Blame PM's poor API.

    Also, I think an assertion for `instanceof Sign` instead of an if is more appropriate.
     
    Skullex and Muqsit like this.
  4. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    PHP:
    $pk = new \pocketmine\network\protocol\BlockEntityDataPacket();
    $data $tile->getSpawnCompound();
    $data->Text1->setValue("Text1","Line1");
    $data->Text2->setValue("Text2","Line2");
    $data->Text3->setValue("Text3","Line3");
    $data->Text4->setValue("Text4","Line4");
    $nbt = new \pocketmine\nbt\NBT(NBT::LITTLE_ENDIAN);
    $nbt->setData($data);
    $pk->$tile->getX();
    $pk->$tile->getY();
    $pk->$tile->getZ();
    $pk->namedtag $nbt->write(true);
    $p->dataPacket($pk);#$p is Player
     
    Last edited: Feb 18, 2017
    Skullex, MioTaku and corytortoise like this.
  5. MioTaku

    MioTaku Witch

    Messages:
    69
    GitHub:
    uselesswaifu
    Yus I wanted to only change text for a certain player

    Thank you
     
  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.