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

Check block

Discussion in 'Development' started by #A6543, Mar 7, 2017.

  1. #A6543

    #A6543 Zombie

    Messages:
    267
    Hello?
     
    Last edited: Mar 8, 2017
    SmartLord likes this.
  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    PHP:
    /** @var $sign Sign */
    /** @var $player Player */
    /** @var $block Block */
    $block $sign->getLevel()->getBlock($sign->add($player->getDirection()->normalize()));
    Behind, relative to what?
     
    Muqsit and Sandertv like this.
  3. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    You're checking if an object is zero, just like the error says. You should use ...->getId().
     
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    I know, I understood you wrongly.
     
  5. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    I think you could try getting the meta of the sign, as it should be different for the direction it is facing. Then make a switch case for those sides and make it $z + 1 or $x - 1 for example.
     
  6. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
  7. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    $block->getSide() will give you object Block
     
  8. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    The link there is your example? Just replace $this inside there with $block, a Block object
    Note: dont just copy the whole function and expect it to work, copy only what you need
     
  9. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    $block is your sign's block
     
  10. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    PHP:
    #$b need to be instanceof Block
    $faces = [
       
    => 3,
       
    => 2,
       
    => 5,
       
    => 4,
      ];
       if(isset(
    $faces[$b->getDamage()])){
        if(
    $b->getSide($faces[$b->getDamage()])->getId() === $someBlockID){

    $this->owner->getServer()->getDefaultLevel()->setBlock($bBlock::get(1,0));
    }

    }
     
  11. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    PHP:
    #$b need to be instanceof Block
    $faces = [
       
    => 3,
       
    => 2,
       
    => 5,
       
    => 4,
      ];
       if(isset(
    $faces[$b->getDamage()])){
        if(
    $b->getSide($faces[$b->getDamage()])->getId() === $someBlockID){

    $this->owner->getServer()->getDefaultLevel()->setBlock($b->getSide($faces[$b->getDamage()]), Block::get(1,0));
    }

    }
     
  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.