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

block under itemFrame

Discussion in 'Development' started by udwarf, Jun 7, 2017.

  1. udwarf

    udwarf Silverfish

    Messages:
    21
    Hello!
    How can I get block under the itemFrame?
    I'm hooking PlayerInteractEvent and when player clicks on the itemFrame I can do $event->getBlock(); to get the itemFrame-block. I even can get tile for this itemFrame. But I do not understand how can I decide to which block this itemFrame is connected?
    I feel its should be somehow easy. please help!

    Tnx in advance!
     
  2. udwarf

    udwarf Silverfish

    Messages:
    21
    Oh. Found a solution.
    Rotation is stored as damage of the block
    So to find target block I have to do something like

    PHP:
    switch ($b->getDamage()) {
       case 
    0:
          
    $pos $pos->add(-1);
          break;
       case 
    1:
          
    $pos $pos->add(+1);
          break;
       case 
    2:
          
    $pos $pos->add(0,0,-1);
          break;
       case 
    3:
          
    $pos $pos->add(0,0,+1);
          break;
    }
     
    SOFe, SalmonDE and corytortoise like this.
  3. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    I believe these constants in the Vector3 class could help. I'm not quite sure though.
    You could also use Vector3->getSide().
     
    SOFe 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.