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

Cancel open door

Discussion in 'Development' started by gistrec, Feb 5, 2017.

  1. gistrec

    gistrec Witch

    Messages:
    68
    GitHub:
    gistrec
    I try cancel PlayerInteractEvent, when Player try to open door
    Event triggers, but $event->setCancelled(true) doesn't work :c
     
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Can you show us your code? Are there any errors?
     
  3. gistrec

    gistrec Witch

    Messages:
    68
    GitHub:
    gistrec
    PHP:
    public function onTap(PlayerInteractEvent $event){
        if (
    $event->getBlock()->getId() == 324){
            
    $event->setCancelled(true);
            
    var_dump(true); // to check, if event is triggeres
        
    }
    }
    in console: (boolean) true
     
  4. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    You should not hardcode IDs.
    Beside that, if the event is cancellable it should work. Maybe a bug?
     
    SkyZone likes this.
  5. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    No, it's because 324 is the ITEM door, 64 is the block id of a wooden door
     
    Jack Noordhuis likes this.
  6. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    Exactly why @robske_110 (Tim) said:
     
    jasonwynn10 and HimbeersaftLP like 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.