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

Solved Boost signs

Discussion in 'Development' started by LucGamesDE, Jun 2, 2017.

  1. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    Hi.
    First I have some code
    PHP:
    //PlayerMoveEvent is $e

    $player $e->getPlayer();
    foreach(
    $player->getBlocksAround() as $b) {
    if(
    $b == Block::get(Block::SIGN)) {
    $player->knockback(/*???*/);
    }
    }

    But this isn't working. I want to boost the player away from the sign. With this code the sign is only detected if the player is over it.
     
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    use AxisAlignedBB to check if player is in front of sign.
     
  3. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    Mh. Can you give me an example?
     
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    PHP:
    $level /*Your level*/
    $tile $level->getTiles();
    foreach (
    $tile as $sign){
    if(
    $sign instanceof Sign){ // pocketmine tile sign not block
    foreach($level->getNearbyEntities(new AxisAlignedBB($sign->10$sign->10$sign->10$sign->10$sign->10$sign->10)) as $ent){
    if(
    $ent instanceof Player){
    //knockback entity
     
    LucGamesDE likes this.
  5. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Check the block ID rather than checking the equality of the whole object. Block damage may otherwise affect.
     
  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.