PHP: public function destoryCheck(BlockBreakEvent $event){ $blockID = $event->getBlockId(); if($blockID==1){ $this->getServer()->broadCastMessage("break"); } } It doesn't work. it says "Call to undefined method pocketmine\event\block\BlockBreakEvent::getBlockId()" (EXCEPTION) I want to make if stone is broken, sendMessage "break"
use PHP: public function onViewBlock(/*IDK :)*/ $event) {$block = $event->getBlock();if ($block->getId() === Block::IDK) {//IDK AGAIN ;)}} Use this code
Stop using loosely equal comparison. Check the difference here The method OP is looking for is Block::getId() Simply get the block object from Event object, if it is present, and call the method above. It will return an integer.
the best way (Full CODE): PHP: public function onBreak(BlockBreakEvent $event) {$player = $event->getPlayer();$block = $event->getBlock();if ($block->getId() === Block::DIAMOND_BLOCK) {$this->getServer()->broadcastmessage("Break");}//for check if block is not Diamond_Block use !== instead ===} DONE.