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

Solved How to cancel the BlockBreakEvent before it happens?

Comments in 'Plugin Development' started by Hotshot_9930, Jul 13, 2015.

  1. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Ive noticed that when you cancell the BlockBreakEvent, the block still breaks for about a split second then reappears. How do I cancel it before the block actually breaks? I've seen it on a few servers so i know its possible.
  2. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,201
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    the one on servers that you meant is that, they set players to adventure mode.
    Andrey Nazarchuk likes this.
  3. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    I cant believe i didnt think of this. Thanks alot though
    Legoboy0215 likes this.
  4. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    If you want cancel this, try:

    PHP:
    public function onInteract(PlayerInteractEvent $ev){
    //Here, you can write something...
    $ev->setCancelled(true);
    }
     
    This is only full feature working (if you don't want use Adventure mode). Unfortunally, it could cancell all touching (So, if you use this for cancelling breaking doors, player can't be able to open/close them)
  5. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Or, edit the PocketMine-MP.phar
  6. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    But it's really laggy and bad option
  7. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    I already know how to cancel events. I thought that there was a way to cancel the BlockBreakEvent before the block actually breaks but @iJoshuaHD's suggestion of adventure mode is working fine.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    A server can't cancel the breaking because it is handled totally client-side.
    TigerHix likes this.

Share This Page

Advertisement