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

[Solved] problem with block under player

Discussion in 'Development' started by kaliiks, Feb 10, 2017.

  1. kaliiks

    kaliiks Zombie

    Messages:
    250
    I check block under player with id 89:3 (Chiseled Stone Brick) but it check normal stonebrick too :/
    PHP:
    public function onMove(PlayerMoveEvent $e){
    $p $e->getPlayer();
    $block $p->getLevel()->getBlock(new Vector3($player->x$player->0.5$player->z));
    if(
    $block->getId() == "98:3"){
    $p->sendMessage("You cant");
    }
    }
     
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    This is because 98:3 is NOT a valid ID. 3 is the Damage of the block/item, and is not in the ID of that block/item. For 98:3, you need to do $block->getId() and $block->getDamage(). Check if ID is 98, and if Damage is also 3.
     
    kaliiks likes this.
  3. kaliiks

    kaliiks Zombie

    Messages:
    250
    It woking thank you!
     
  4. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Glad I could help. :)
     
    kaliiks likes this.
  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.