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

Cancel door open/close event

Comments in 'Plugin Development' started by deot, Oct 30, 2015.

  1. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Hi,
    I wanted to lock door, block players from opening or closing the door

    I already cancel the PlayerInteractEvent, and it's working for other block like chest :)

    But... door isnt working... Pls help
    EvolSoft likes this.
  2. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    I've the same problem. If you look on older threads I already posted this question
    PEMapModder likes this.
  3. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
  5. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Hahaha... :p Resapwn? I mean to block the door interaction, not BreakBlock ... xD LOL Its PlayerInteractEvent
    iDirtPlayzMC likes this.
  6. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    PHP:
    if(!$e->getBlock() instanceof WoodDoor){
               
    $e->$e->getBlock()->onActivate(null$p);
    }
    I tried this code.... Don't work too...
    Anybody? Help :)
    Legoboy0215 likes this.
  7. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    why do you have
    $e->$e
  8. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    LOL... My typo... xD
    Anyway, it's still not working... zzz
  9. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Check when the player interacts with a door, if the door is supposed to be locked, replace the interacted door with a new closed door.
    deot likes this.
  10. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    But i dont know how can I achieve that... zzz Is it possible to replace interacted door?... Code?
  11. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    PHP:
    Level::setBlock(new Vector3($event->getBlock(), Block::get(pocketmine\block\Door)));
    Last edited: Oct 31, 2015
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Wat, new Vector3(Block, Block)?
    And Block::get(Door)?
    You should just use Level::setBlock(Vector3, Block)
    Such as
    $event->getBlock()->getLevel()->setBlock($event->getBlock(), Block::get(Item::DOOR, /* damage it should be */));
  13. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Thanks for the correction.
  14. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    @Hotshot_9930 Next time remember that Vector3, Vector2 and Vector1 represent positions in the Cartesian axes :p. The first needs three parameters (X, Y, Z position), the second needs two parameters (usually X, Y position) and the third just one (usually X).
    Hotshot_9930 likes this.
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why we need an object for Vector1 while it is already just a number? :D
    Legoboy0215 likes this.
  16. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Hahaha you're right! I'm of your opinion but some game engines have the Vector1 class
    PEMapModder likes this.
  17. TheMaks
    Offline

    TheMaks Active Member

    Joined:
    Jul 19, 2015
    Posts:
    58
    Minecraft User:
    TheMaks
    PHP:
    public function onInteract(PlayerInteractEvent $e){
    if(
    $e->getBlock() == Block::get(/*Door id*/))
    {
       
    $e->getPlayer()->sendMessage("You open door");
    }
    }
    Last edited: Nov 2, 2015
  18. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Please stop providing invalid solutions, you're confusing him. And stop posting code that has already been posted, I can see that you're copying the code from an above post(which is also wrong). Please learn PHP.
  19. andre_the_gamer
    Offline

    andre_the_gamer Active Member

    Joined:
    Feb 5, 2015
    Posts:
    112
    Minecraft User:
    Andre_The_Gamer
    @TheMaks
    Also, :rolleyes:that has nothing to do with canceling open / close door event. It's just send the player message when they touch a door :p

    Anyway.. @deot a
    .. this might work::D |

    PHP:
    <?php


    ## Plugin Was Made By: AndreTheGamer //Or Andre_The_Gamer
    ## GITHUB: www.gitgub.com/AndreTheGamer
    namespace Andre;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\Player;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    class 
    Main extends PluginBase implements Listener {

        public function 
    onEnable(){
            
    $this->getLogger()->info("LightingJoin enabled!");
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
     
        public function 
    onInteract(PlayerInteractEvent $event){
            
    $event->setCancelled(); // This will cancel the event
        
    }
           
        public function 
    onBlockPlace(BlockPlaceEvent $event){
            
    $event->setCancelled(); // This will cancel the event
        
    }
    }
    Uh, i've made one that's TP player to HUB when they interact with a door, Bur ehh that's not what your looking for :D. I hope the one i just provided works.


  20. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Nope, this won't work, I already coded long ago... before I created this thread Cancel PlayerInteractEvent will just cancel the interaction with chest/furance etc

Share This Page

Advertisement