Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[New API] Canceling door event

Comments in 'Plugin Development' started by Dutok, Jul 10, 2014.

  1. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    371
    Plugins:
    3
    Minecraft User:
    Dutok
    I'm trying to 'lock' doors but when I cancel the door event it only works when I right click the 'bottom' part while holding something.

    I think there might be a way to 'cancel' it using metadata but I don't know where to start. Any ideas?
  2. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    Try setting the block manually
  3. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    371
    Plugins:
    3
    Minecraft User:
    Dutok
    What do you mean?
  4. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    If $event->setCancelled() doesn't work, set the door block manually to what it was before
  5. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    371
    Plugins:
    3
    Minecraft User:
    Dutok
    Oh! Good idea. I will try that. :)
  6. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    371
    Plugins:
    3
    Minecraft User:
    Dutok
    It didn't work. The block stayed the same. :confused:
  7. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    I imagine something like:
    PHP:
    public function onBlockTap(PlayerInteractEvent $event)
    $block $event->getBlock();
    if(
    $block instanceof Door){
         
    //if door is blocked or something else...
         
    $event->setCancelled();
    }
    but @Lambo said that it doesn't work, so I don't get anything yet xD
  8. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    371
    Plugins:
    3
    Minecraft User:
    Dutok
    I tried that before coming here.. It doesn't work.
  9. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    ok :p
  10. DarkN3ss
    Offline

    DarkN3ss Active Member Plugin Developer

    Joined:
    Dec 17, 2013
    Posts:
    143
    Plugins:
    7
    Minecraft User:
    DarkN3ss61
    Just an idea, do you have another device? because do the '$event->setCancelled();" and on one device try open it and walk through ando n the other device check if it actually opened because on 1.3 there was this issue where it wasn't opening for anyone else except for the player trying to open it
    Tuff likes this.
  11. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,707
    Plugins:
    22
    Minecraft User:
    Falkirknh
    The client could be sending the interact packet and assuming the door is open.
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    And? This applies to all blocks.
  13. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,707
    Plugins:
    22
    Minecraft User:
    Falkirknh
    What do you mean?
  14. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    371
    Plugins:
    3
    Minecraft User:
    Dutok
    Most blocks don't open so I don't know what you mean by that.

    Only doors seem to have this weird quirk because I can cancel furnaces and chests. This is probably (definitely) because of it being separated into 2 blocks and the playerinteractevent only seems to fire when you interact while holding something, so no empty hand.
    PEMapModder likes this.
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I think what door is different is, opening doors is not simply an action or setting blocks client-side.

Share This Page

Advertisement