Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Interact sign

Comments in 'Plugin Development' started by JackboyPlay, Jun 2, 2016.

  1. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    How can I set the text on a sign in PlayerInteractEvent?
  2. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Is it so difficult?
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    So, I guess you know how to check if it is a sign, since you didn't ask for it.
    Having the sign, you can use Sign::setText() - pretty easy, right?

    Please use better descriptions of your problems/what you want. We are still humans and cannot look into your PC. You can get it by Level::getTile($pos) and check if the tile is instanceof Sign.
    HotFireyDeath and Jazzwhistle like this.
  4. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    PHP:
    public function onInteract(PlayerInteractEvent $event){
    $player $event->getPlayer();
    $block $event->getBlock();
    $tile $event->getPlayer()->getLevel()->getTile($block);
    if(
    $tile instanceof Sign){
    $tile->setText("§b[Enchant§b]"$this->sign[$player->getName()], "§aLevel: §e" $this->sign2[$player->getName()], "§c" $this->sign2[$player->getName()] . "$");
    }
    }
    Why does that not work?!?
  5. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Most likely you didnt add
    PHP:
     use pocketmine\tile\Sign
  6. udwarf
    Offline

    udwarf Active Member

    Joined:
    Apr 17, 2016
    Posts:
    61
    Minecraft User:
    1Zaza
    Also it could be WallSign instead of Sign
  7. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    That is a bad practice.
    The best way to check if it's a Sign, is checking the ID.
    PHP:
    public function onInteract(PlayerInteractEvent $event) {
            
    $id $event->getBlock()->getId();
            if (
    $id == Block::WALL_SIGN or $id == Block::SIGN_POST) {
                
    // code
            
    }
        }
    Survingo likes this.
  8. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Nope, definitely NOT
    The best way of checking if it's a sign block is that what you did
    But if you want to set text, you need the tile
    And therefore checking if the tile exist is the best way
  9. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Eh, you know what constant mean?
    The scope resolution operator ("::") let access to a class static stuff, like a constant, a static variable or a static function.
    http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php
    "Block::WALL_SIGN" returns wall sign ID... Ejem... There's no difference between use Block::WALL_SIGN or use 68 directly.

    Please, if you don't know something, DON'T REPLY.
    Last edited: Jun 6, 2016
  10. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    WTF? I said checking for the TILE not checking the block ID
    I do indeed know what's static stuff.
    You just do not seem to read correctly

Share This Page

Advertisement