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

Cancel bedrock deetruction

Discussion in 'Help' started by _XHazardX_, Oct 24, 2017.

  1. _XHazardX_

    _XHazardX_ Spider Jockey

    Messages:
    33
    GitHub:
    XHazardX420
    Hello, how can I make it so u can't destroy in any form bedrock at y lvl 1?
     
  2. KittyDev

    KittyDev Slime

    Messages:
    96
    GitHub:
    FreakingDev
    cancel it
     
    NickTehUnicorn likes this.
  3. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    lmao
     
  4. KittyDev

    KittyDev Slime

    Messages:
    96
    GitHub:
    FreakingDev
    am i right XD
     
  5. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    yeah just "cancel it" xD
     
  6. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    Cancel the BlockBreakEvent if Bedrock gets broken in level/world called lvl1:
    PHP:
    public function onBlockBreakEvent(BlockBreakEvent $event) {
        
    $block $event->getBlock(); // gets the broken block
        
    if($block->getLevel()->getName() === "lvl1") { // checks if the block’s level/world is “lvl1”
            
    if($block->getId() === Block::BEDROCK) { // if the broken block is bedrock
                
    $event->setCancelled(); // cancels the event, player cannot break bedrock
            
    }
        }
    }
     
    Last edited: Oct 29, 2017
    QuiverlyRivalry and jojoe77777 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.