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

Solved how to open ui when touch chest

Discussion in 'Plugin Help' started by xPen17, Sep 13, 2020.

  1. xPen17

    xPen17 Creeper

    Messages:
    3
    GitHub:
    xPen17
  2. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    Check if the player is interacting with a chest, if so, send him a form
     
  3. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    check PlayerInteractEvent ->getBlock()
     
    Last edited: Sep 30, 2020
  4. xPen17

    xPen17 Creeper

    Messages:
    3
    GitHub:
    xPen17
    ty
     
  5. Dyntes

    Dyntes Spider Jockey

    Messages:
    48
    GitHub:
    Dyntes
    I think this event is execute when player want to place chest...Not opening chest...(I think)
     
  6. Dyntes

    Dyntes Spider Jockey

    Messages:
    48
    GitHub:
    Dyntes
    I think it should be
    PHP:
    public function onInteract(PlayerInteractEvent $event){
         
    $player $event->getPlayer();
         
    $itemTapped $event->getBlock();
         if(
    $itemTapped->getName() == "chest"){//get the block by name
         //Open the UI
         
    }
    }
     
  7. Wanny

    Wanny Spider

    Messages:
    8
    You need to cancel event
     
  8. Dyntes

    Dyntes Spider Jockey

    Messages:
    48
    GitHub:
    Dyntes
    Ohh... I forgot about it hehe...
     
  9. Dyntes

    Dyntes Spider Jockey

    Messages:
    48
    GitHub:
    Dyntes
    Bottom of it you should put...
    PHP:
    $event->setCancelled();
     
  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.