How do you check if a door (Or any block that you can open or close) is open?

Discussion in 'Development' started by Indexfire, Sep 8, 2020.

  1. Indexfire

    Indexfire Baby Zombie

    Messages:
    135
    GitHub:
    Indexfire
    This one's been bugging me for a while. I'm trying to build a NavMesh in my plugin and I need to check if Doors/Fence Gates and whatnot are open, but since Pocketmine uses the legacy Block Meta system instead of the new BlockStates, how would I efficiently check if the door at the node is open or close so I can mark the node as walkable/not walkable? It seems like a really bad way if I just went else if else if else if else if getDamage() == <Whatever the block meta that marks a door as open is>. And making this worse is that doors and gates have different orientations, meaning there's even more block metas to check
     
  2. Primus

    Primus Zombie Pigman

    Messages:
    459
    The way you've shown is the only way as far as I know. The block state is saved in the meta data, as you stated.

    It's possible that they're implementing BlockStates in PocketMine v4.0.0. I will confirm this, and edit this post asap.
     
  3. Indexfire

    Indexfire Baby Zombie

    Messages:
    135
    GitHub:
    Indexfire
    :/

    Looks like it's time for me to build an array of metadata values... again... Hopefully BlockStates come soon at least
     

Share This Page

  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.