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

How to indentify the meta and set the stairs to an different direction on setBlock?

Discussion in 'Development' started by LewBr, Mar 6, 2018.

  1. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Hello i have this:
    PHP:
    $pos->getLevel()->setBlock(new Position($pos->x$pos->y$pos->z$pos->getLevel()), $blockfalsefalse);
    $block2 are the id of the stair that i want: "134" and i want to set the rotation of the stair to top, right, left, or bottom, so how can i do that? I have see on this:
    https://github.com/pmmp/PocketMine-...1630823b7b/src/pocketmine/block/Stair.php#L92

    but i don't know how to do this whitout need that the player is looking to top or bottom on yaw..
     
    Last edited: Mar 10, 2018
    MasterPE likes this.
  2. CreeperFace

    CreeperFace Witch

    Messages:
    58
    GitHub:
    creeperface01
    Hi, the first 2 bits of metadata are for the stairs rotation, and with the third bit you can set vertical rotation to the top or bottom.
     
  3. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    How can i get and set the metadata by this code that i have? setBlock? can you tell me :p?
     
    MasterPE likes this.
  4. CreeperFace

    CreeperFace Witch

    Messages:
    58
    GitHub:
    creeperface01
    PHP:
    $meta $block->getDamage();

    $meta &= 0x00//one of horizontal rotations
    $meta &= 0x01//one of horizontal rotations
    $meta &= 0x02//one of horizontal rotations
    $meta &= 0x03//one of horizontal rotations

    //you can change horizontal direction with
    $meta ^= 0x04//change vertical rotation
    should work
     
    LewBr likes this.
  5. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Hello, but how can i indetify the meta to an block? Because i get the block by using this:
    PHP:
     $block Item::fromString("136:0")->getBlock();
        
    $this->getServer()->getLevelByName($level)->setBlock(new Position($x$y$z$this->getServer()->getLevelByName($level)), $blockfalsefalse);
    So, who can i set the meta to this?
     
    Last edited: Mar 10, 2018
  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.