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
https://forums.pocketmine.net/threa...oesnt-cancel-correctly-door-event.7562/page-2 I found yours thread... But it is not solved yet... isn't?
Hahaha... Resapwn? I mean to block the door interaction, not BreakBlock ... xD LOL Its PlayerInteractEvent
PHP: if(!$e->getBlock() instanceof WoodDoor){ $e->$e->getBlock()->onActivate(null, $p);} I tried this code.... Don't work too... Anybody? Help
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.
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:OOR, /* damage it should be */));
@Hotshot_9930 Next time remember that Vector3, Vector2 and Vector1 represent positions in the Cartesian axes . 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).
PHP: public function onInteract(PlayerInteractEvent $e){if($e->getBlock() == Block::get(/*Door id*/)){ $e->getPlayer()->sendMessage("You open door");}}
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.
@TheMaks Also, that has nothing to do with canceling open / close door event. It's just send the player message when they touch a door Anyway.. @deot a .. this might work: | PHP: <?php## Plugin Was Made By: AndreTheGamer //Or Andre_The_Gamer## GITHUB: www.gitgub.com/AndreTheGamernamespace 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 . I hope the one i just provided works.
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