PHP: public function onPlace(\pocketmine\event\block\BlockPlaceEvent $event){ $block = $event->getBlock(); $player = $event->getPlayer(); if($block->getId() == 46){ $event->setCancelled(); $player->sendMessage("§cYou can't place TNT."); } }
why not just use the subtract function? PHP: $player->subtract(0,1); p.s. There's no need to use the third parameter if it's going to be zero, because it's set at zero by default.
You shouldn't even use the subtract function Block::getSide() returns a Block instance. Plus, block below the player is not the block below the block you are mining. PHP: /** @var BlockBreakEvent $event */if($event->getBlock()->getSide(Vector3::SIDE_DOWN)->getId() === Block::GRASS){ $event->setCancelled();}
This is arguably the best solution. I didn't even read the original post. I just saw someone using the add function with negative parameters and shook my fist in raging anger.