Hey guys, I'm new to pocketmine but I used to code spigot plugins. I was wondering how I could check if a player breaks the kelp plant in the ocean? Here's my code public function onBlockBreak(BlockBreakEvent $event) : void { $block = $event->getBlock()->getId(); $p = $event->getPlayer(); if($block === BLOCK::KELP_PLANT){ $p->sendMessage("You broke some kelp."); } else { $p->sendMessage("You didn't break kelp."); } } It seems that KELP_PLANT isn't a thing. KELP also doesn't work. I get an internal error disconnect whenever I break a block. Any ideas? Thanks!
An internal error prints the error in the console. Errors let you know which line in your code has an error. You can read the error message or if you still don't understand the error, paste the message here.
Hey, Thanks for responding. The error tells me that "BLOCK::KELP_PLANT" isn't a block basically. What is the block ID for the kelp in the game that grows underwater? The green stuff lol? I just want to check when ppl break it. Steven
Okay, thanks. What do u mean pocketmine doesn't generate it? Like kelp doesn't grow in pocket edition?
Ah. Can I place the kelp myself in water? And should this code work to check if someone breaks the kelp? public function onBlockBreak(BlockBreakEvent $event) : void { $block = $event->getBlock()->getId(); $p = $event->getPlayer(); if($block === 393){ $p->sendMessage("You broke some kelp."); } else { $p->sendMessage("You didn't break kelp."); } }
DO NOT HARD-CODE BLOCK IDS Sooner or later, mojang would change block IDs and you'll need to go through all your code and replace the 393 with the new block IDs. Use Block::KELP constant instead.
Hey, yeah I tried that but it doesn't know what "KELP" is so you get an internal error. I've changed around my strategy because I didn't know the world didn't generate kelp and I'm fine now. Thanks for the help guys!