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

Solved Distinguish blocks with some function from other blocks

Discussion in 'Development' started by Tee7even, Apr 5, 2018.

  1. Tee7even

    Tee7even Slime

    Messages:
    81
    GitHub:
    tee7even
    This actually concerns a pretty old change in PM that was made over a year ago, but I was looking through some of my old plugins and found out that Block::canBeActivated method was removed. And now I have a question: does PM no longer provide a way to distinguish such "activable" block from any other block? Say, I'm cancelling a PlayerInteractEvent and I want to send a message to players when they click on a block, but not just any block, an "activable" block. If there's no interface in PM for this, then I would like to hear for any other ways to check for this which don't involve making a list of such blocks.
     
  2. VirVolta

    VirVolta Silverfish

    Messages:
    16
    GitHub:
    VirvoltaSurMC
    you can do with a type of block or with the cordonner of a block
     
  3. di2134876

    di2134876 Spider Jockey

    Messages:
    29
    GitHub:
    dk1234987
    What do you mean by "activable"?

    You can easy do PlayerInteractEvent and check the block's id to what ever you want.
     
  4. Tee7even

    Tee7even Slime

    Messages:
    81
    GitHub:
    tee7even
    PHP:
        /**
         * AKA: Block->isActivable
         *
         * @return bool
         */
        
    public function canBeActivated(){
            return 
    false;
        }


    [​IMG]
     
  5. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    no, there isn't any way to identify these blocks. That method should be moved to an interface. That's an enhancement I intend to do in the future.
     
    Tee7even likes this.
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    "Activatable" is a vanilla-only concept. It doesn't apply when there come other plugins. For instance, would you consider a warp sign to be activatable?
     
  7. Tee7even

    Tee7even Slime

    Messages:
    81
    GitHub:
    tee7even
    No. A "warp sign" is still a sign nonetheless. Plugins cannot add a brand new block to the game.
     
  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.