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

Unbreakable Blocks plugin (new)

Comments in 'Plugin Development' started by WillotheBlessed, Sep 19, 2014.

Thread Status:
Not open for further replies.
  1. WillotheBlessed
    Offline

    WillotheBlessed Active Member

    Joined:
    Sep 17, 2014
    Posts:
    69
    Minecraft User:
    will
    I found a previous "unbreakable blocks" mod but it's using the old API. So I started testing out a few ideas, but only got this far when I realized this didn't work.

    Code:
    public function onPlayerInteract(PlayerInteractEvent $event)
        {
            if ($event->getBlock()->getID() > 0 && $event->getBlock()->getID() < 248)
            {      
                $event->getBlock()->breakable = false;
                $this->getLogger()->info("HItting block and trying to set to unbreakable");
            }
             $this->getLogger()->info("player interacts with object");
        }
    
        public function onBreakBlock(BlockBreakEvent $event)
        {
            $event->getBlock()->breakable = false;
            $this->getLogger()->info("Breaking block event");
        }
    
    
    
    The events are firing, but the blocks are still breakable. Is there something I'm doing wrong? If so, I'd like to learn something from this about why setting a block to (breakable=false) isn't working.



    Thanks.
  2. WillotheBlessed
    Offline

    WillotheBlessed Active Member

    Joined:
    Sep 17, 2014
    Posts:
    69
    Minecraft User:
    will
    Nevermind, I found the AreaProtect plugin and it seems to do what I want it to do.
Thread Status:
Not open for further replies.

Share This Page

Advertisement