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

Certain blocks breakable in a world

Discussion in 'Development' started by str0nix, Sep 23, 2020.

  1. str0nix

    str0nix Spider Jockey

    Messages:
    33
    GitHub:
    str0nixofficial
    Greetings,

    I would make a code which for example let’s players break stone blocks in a world but the other blocks doesn’t. I’m new at coding, so I need some help with this. Hope you could understand. Thanks a lot in advance!
     
  2. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    PHP:
    public function onBreak(BlockBreakEvent $event): void {
        if(
    $event->getPlayer()->getLevel()->getName() === "level name") {
            
    $event->setCancelled();
        }
    }
    You could also use switch() if you want to check multiple worlds
     
    minijaham likes this.
  3. str0nix

    str0nix Spider Jockey

    Messages:
    33
    GitHub:
    str0nixofficial
    Thank you
     
  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.