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

Get the bed position

Discussion in 'Development' started by TobyD, Apr 2, 2021.

  1. TobyD

    TobyD Creeper

    Messages:
    5
    GitHub:
    tobydev265
    Can anyone help me to get the position of the bed when player touch it!
     
  2. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    PlayerInteractEvent?
    PHP:
    $block $event->getBlock();
    if (
    $block === Block::BED) { // Have a check for if the block interacted with is a bed block. Not sure if this is right though.
           
    $x $block->getX();
           
    $y $block->getY();
           
    $z $block->getZ();
           echo 
    'Bed Block detected at '.$x.'X '.$y.'Y '.$z.'Z';
    }
     
  3. TobyD

    TobyD Creeper

    Messages:
    5
    GitHub:
    tobydev265
    thanks
     
    minijaham 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.